diff --git a/packages/babel-cli/src/babel/dir.js b/packages/babel-cli/src/babel/dir.js index ebd86380b7..6bdb2fc194 100644 --- a/packages/babel-cli/src/babel/dir.js +++ b/packages/babel-cli/src/babel/dir.js @@ -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(); diff --git a/packages/babel-cli/src/babel/file.js b/packages/babel-cli/src/babel/file.js index 9dd8789c1b..36195ca722 100644 --- a/packages/babel-cli/src/babel/file.js +++ b/packages/babel-cli/src/babel/file.js @@ -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(); diff --git a/packages/babel-cli/src/babel/index.js b/packages/babel-cli/src/babel/index.js index f23f6f43d1..1894d55d24 100755 --- a/packages/babel-cli/src/babel/index.js +++ b/packages/babel-cli/src/babel/index.js @@ -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);