Merge pull request #3489 from lxe/optinal-nocompile-watch

babel-cli: add --skip-initial-build option to only compile on changes when watching
This commit is contained in:
Logan Smyth 2016-05-30 14:29:30 -07:00
commit 85ec7834d0
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);