Watching for changes in the dc09.js script
This commit is contained in:
parent
fa88138bc2
commit
3856235544
1 changed files with 14 additions and 0 deletions
14
dc09.js
14
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 <dir>',
|
||||
'archive',
|
||||
|
|
Loading…
Add table
Reference in a new issue