Skip to content

Commit

Permalink
bug fix for watch-content.js
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Jan 18, 2023
1 parent 365c898 commit 506d913
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions bin/watch-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const compileFile = require('./compile.js');
const fse = require("fs-extra");
const chokidar = require('chokidar');
const partials = require('./partials.js');
const src = 'app/content';
const utils = require('./utils.js');
const path = require('path');
const config = require('./config.js');
Expand All @@ -12,7 +11,7 @@ const watcher = chokidar.watch('.', {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true,
ignoreInitial: true,
cwd: src
cwd: 'app/content'
});

// Something to use when events are received.
Expand All @@ -32,19 +31,20 @@ watcher
.on('change', filepath => {
log(`File ${filepath} has been changed`);
const folder = path.dirname(filepath);
console.log('folder: ', folder);
if (filepath.indexOf('assets') >= 0) {
console.log('Copying asset to public folder...');
copyFile(filepath);
} else {
let sourceFolder = 'app/content/';
if (folder.indexOf('partials') >= 0) {
sourceFolder += folder.replace('/partials', '');
} else {
sourceFolder += folder.replace('/pages', '');
}
const str = folder.indexOf('partials') >= 0 ? 'partials' : 'pages';
const index = folder.indexOf(str);
const subfolder = folder.substring(0, index);
const sourceFolder = 'app/content' + '/' + subfolder;

console.log('Compiling all pages...');
console.log('sourceFolder: ', sourceFolder);
config.pages.forEach(page => {
if (page.source === sourceFolder) {
if (page.source + '/' === sourceFolder) {
partials.registerPartials(page.source + '/partials');
utils.traverseDir(page.source + '/pages', function(path) {
compileFile(path, page.source, page.target);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "0.1.8",
"version": "0.1.9",
"description": "A frontend build for HTML Websites",
"repository": {
"type": "git",
Expand Down

0 comments on commit 506d913

Please sign in to comment.