Add simplified watch

This commit is contained in:
Tom Raithel
2017-02-10 19:50:03 +01:00
parent 54ecb46956
commit 0673da6867
4 changed files with 47 additions and 5 deletions

View File

@@ -13,6 +13,18 @@ export const staticPath = (...pathInSrc) => (
relativePath('static-pages', ...pathInSrc)
);
export const templatesPath = (...pathInSrc) => (
relativePath('templates', ...pathInSrc)
);
export const stylesPath = (...pathInSrc) => (
relativePath('styles', ...pathInSrc)
);
export const jsPath = (...pathInSrc) => (
relativePath('js', ...pathInSrc)
);
export const distPath = (...pathInDist) => (
relativePath('dist', ...pathInDist)
);

33
tasks/watch.js Normal file
View File

@@ -0,0 +1,33 @@
import { watch } from 'fs';
import { exec } from 'child_process';
import {
stylesPath,
jsPath,
radarPath,
staticPath,
templatesPath,
} from './file';
const watchBuild = (name) => (eventType, fileName) => {
exec(`npm run build:${name}`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(stdout);
console.error(stderr);
})
}
const options = {
recursive: true,
}
watch(stylesPath(), options, watchBuild('css'));
watch(jsPath(), options, watchBuild('js'));
watch(radarPath(), options, watchBuild('pages'));
watch(staticPath(), options, watchBuild('pages'));
watch(templatesPath(), options, watchBuild('pages'));
console.log('Watching for changes, press CTRL+C to quit');