diff --git a/dc09.js b/dc09.js index e837d52..7f4876a 100644 --- a/dc09.js +++ b/dc09.js @@ -12,6 +12,7 @@ const exec = (cmd) => { console.log(`Exec: ${cmd}`) return cp.execSync(cmd) } +const cwd = process.cwd() const CleanCSS = require('clean-css') const Handlebars = require('handlebars') @@ -38,6 +39,18 @@ main() function main() { switch (process.argv[2]) { + case 'watch': + fs.watch(cwd, {recursive: true}, (_ev, file) => { + const rel = path.relative(cwd, file) + if (rel.includes('dist/')) + return + print(`Changed: ${file}`, true, '#', yellow) + const dirs = rel.split(path.sep) + const dir = (dirs.length > 1) ? dirs[0] : '.' + buildOne(dir) + }) + break + case 'build': const dir = process.argv[3] if (dir) @@ -57,6 +70,7 @@ function main() { default: print('Available actions:', true) printList([ + 'watch', 'build', 'build ', 'archive',