cli: --skip-initial-build option to compile only on watched changes

This commit is contained in:
Aleksey Smolenchuk 2016-04-29 18:58:52 -07:00
parent 13c961d29d
commit 4bf6f8ab18
3 changed files with 12 additions and 2 deletions

View File

@ -61,7 +61,9 @@ module.exports = function (commander, filenames) {
}
}
_.each(filenames, handle);
if (!commander.skipInitialBuild) {
_.each(filenames, handle);
}
if (commander.watch) {
let chokidar = util.requireChokidar();

View File

@ -129,7 +129,10 @@ module.exports = function (commander, filenames, opts) {
};
let files = function () {
walk();
if (!commander.skipInitialBuild) {
walk();
}
if (commander.watch) {
let chokidar = util.requireChokidar();

View File

@ -40,6 +40,7 @@ each(options, function (option, key) {
commander.option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx]");
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-s, --skip-initial-build", "Do not compile files before watching");
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");
@ -92,6 +93,10 @@ if (commander.watch) {
}
}
if (commander.skipInitialBuild && !commander.watch) {
errors.push("--skip-initial-build requires --watch");
}
if (errors.length) {
console.error(errors.join(". "));
process.exit(2);