Comparing version 7.0.0-alpha.20 to 7.0.0-beta.0
@@ -54,2 +54,6 @@ "use strict"; | ||
case "--expose-http2": | ||
args.unshift("--expose-http2"); | ||
break; | ||
case "--nolazy": | ||
@@ -56,0 +60,0 @@ args.unshift(flag); |
@@ -6,3 +6,3 @@ "use strict"; | ||
exports.default = function (commander, filenames, opts) { | ||
function write(src, relative) { | ||
function write(src, relative, base) { | ||
if (!util.isCompilableExtension(relative, commander.extensions)) { | ||
@@ -12,6 +12,4 @@ return false; | ||
relative = relative.replace(/\.(\w*?)$/, "") + ".js"; | ||
var dest = _path2.default.join(commander.outDir, relative); | ||
relative = util.adjustRelative(relative, commander.keepFileExtension); | ||
var dest = getDest(commander, relative, base); | ||
var data = util.compile(src, (0, _defaults2.default)({ | ||
@@ -35,8 +33,12 @@ sourceFileName: (0, _slash2.default)(_path2.default.relative(dest + "/..", src)), | ||
function handleFile(src, filename) { | ||
var didWrite = write(src, filename); | ||
function getDest(commander, filename, base) { | ||
if (commander.relative) return _path2.default.join(base, commander.outDir, filename); | ||
return _path2.default.join(commander.outDir, filename); | ||
} | ||
function handleFile(src, filename, base) { | ||
var didWrite = write(src, filename, base); | ||
if (!didWrite && commander.copyFiles) { | ||
var dest = _path2.default.join(commander.outDir, filename); | ||
var dest = getDest(commander, filename, base); | ||
(0, _outputFileSync2.default)(dest, _fs2.default.readFileSync(src)); | ||
@@ -54,9 +56,14 @@ util.chmod(src, dest); | ||
var dirname = filename; | ||
if (commander.deleteDirOnStart) { | ||
util.deleteDir(commander.outDir); | ||
} | ||
util.readdir(dirname).forEach(function (filename) { | ||
var src = _path2.default.join(dirname, filename); | ||
handleFile(src, filename); | ||
handleFile(src, filename, dirname); | ||
}); | ||
} else { | ||
write(filename, filename); | ||
write(filename, _path2.default.basename(filename), _path2.default.dirname(filename)); | ||
} | ||
@@ -63,0 +70,0 @@ } |
@@ -100,2 +100,4 @@ #!/usr/bin/env node | ||
_commander2.default.option("--keep-file-extension", "Preserve the file extensions of the input files"); | ||
_commander2.default.option("-w, --watch", "Recompile files on changes"); | ||
@@ -109,2 +111,4 @@ | ||
_commander2.default.option("--relative", "Compile into an output directory relative to input directory or file. Requires --out-dir [out]"); | ||
_commander2.default.option("-D, --copy-files", "When compiling a directory copy over non-compilable files"); | ||
@@ -114,2 +118,4 @@ | ||
_commander2.default.option("--delete-dir-on-start", "Delete's the out directory before compilation"); | ||
_commander2.default.version(_package2.default.version + " (babel-core " + _babelCore.version + ")"); | ||
@@ -145,2 +151,6 @@ | ||
if (_commander2.default.relative && !_commander2.default.outDir) { | ||
errors.push("output directory required for --relative"); | ||
} | ||
if (_commander2.default.watch) { | ||
@@ -160,2 +170,6 @@ if (!_commander2.default.outFile && !_commander2.default.outDir) { | ||
if (_commander2.default.deleteDirOnStart && !_commander2.default.outDir) { | ||
errors.push("--delete-dir-on-start requires --out-dir"); | ||
} | ||
if (errors.length) { | ||
@@ -181,2 +195,4 @@ console.error(errors.join(". ")); | ||
delete opts.configFile; | ||
delete opts.deleteDirOnStart; | ||
delete opts.keepFileExtension; | ||
if (opts.babelrc === true) opts.babelrc = undefined; | ||
@@ -183,0 +199,0 @@ if (opts.comments === true) opts.comments = undefined; |
@@ -12,3 +12,5 @@ "use strict"; | ||
exports.compile = compile; | ||
exports.deleteDir = deleteDir; | ||
exports.requireChokidar = requireChokidar; | ||
exports.adjustRelative = adjustRelative; | ||
@@ -93,2 +95,18 @@ var _commander = require("commander"); | ||
function deleteDir(path) { | ||
if (_fs2.default.existsSync(path)) { | ||
_fs2.default.readdirSync(path).forEach(function (file) { | ||
var curPath = path + "/" + file; | ||
if (_fs2.default.lstatSync(curPath).isDirectory()) { | ||
deleteDir(curPath); | ||
} else { | ||
_fs2.default.unlinkSync(curPath); | ||
} | ||
}); | ||
_fs2.default.rmdirSync(path); | ||
} | ||
} | ||
function toErrorStack(err) { | ||
@@ -114,2 +132,10 @@ if (err._babel && err instanceof SyntaxError) { | ||
} | ||
} | ||
function adjustRelative(relative, keepFileExtension) { | ||
if (keepFileExtension) { | ||
return relative; | ||
} | ||
return relative.replace(/\.(\w*?)$/, "") + ".js"; | ||
} |
{ | ||
"name": "babel-cli", | ||
"version": "7.0.0-alpha.20", | ||
"version": "7.0.0-beta.0", | ||
"description": "Babel command line.", | ||
@@ -19,5 +19,5 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"babel-core": "7.0.0-alpha.20", | ||
"babel-polyfill": "7.0.0-alpha.20", | ||
"babel-register": "7.0.0-alpha.20", | ||
"babel-core": "7.0.0-beta.0", | ||
"babel-polyfill": "7.0.0-beta.0", | ||
"babel-register": "7.0.0-beta.0", | ||
"commander": "^2.8.1", | ||
@@ -37,3 +37,3 @@ "convert-source-map": "^1.1.0", | ||
"devDependencies": { | ||
"babel-helper-fixtures": "7.0.0-alpha.20" | ||
"babel-helper-fixtures": "7.0.0-beta.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29663
724
+ Addedbabel-code-frame@7.0.0-beta.0(transitive)
+ Addedbabel-core@7.0.0-beta.0(transitive)
+ Addedbabel-generator@7.0.0-beta.0(transitive)
+ Addedbabel-helper-function-name@7.0.0-beta.0(transitive)
+ Addedbabel-helper-get-function-arity@7.0.0-beta.0(transitive)
+ Addedbabel-helpers@7.0.0-beta.0(transitive)
+ Addedbabel-messages@7.0.0-beta.0(transitive)
+ Addedbabel-polyfill@7.0.0-beta.0(transitive)
+ Addedbabel-register@7.0.0-beta.0(transitive)
+ Addedbabel-template@7.0.0-beta.0(transitive)
+ Addedbabel-traverse@7.0.0-beta.0(transitive)
+ Addedbabel-types@7.0.0-beta.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedms@2.1.3(transitive)
- Removedbabel-code-frame@7.0.0-alpha.20(transitive)
- Removedbabel-core@7.0.0-alpha.20(transitive)
- Removedbabel-generator@7.0.0-alpha.20(transitive)
- Removedbabel-helper-function-name@7.0.0-alpha.20(transitive)
- Removedbabel-helper-get-function-arity@7.0.0-alpha.20(transitive)
- Removedbabel-helpers@7.0.0-alpha.20(transitive)
- Removedbabel-messages@7.0.0-alpha.20(transitive)
- Removedbabel-polyfill@7.0.0-alpha.20(transitive)
- Removedbabel-register@7.0.0-alpha.20(transitive)
- Removedbabel-template@7.0.0-alpha.20(transitive)
- Removedbabel-traverse@7.0.0-alpha.20(transitive)
- Removedbabel-types@7.0.0-alpha.20(transitive)
Updatedbabel-core@7.0.0-beta.0
Updatedbabel-polyfill@7.0.0-beta.0
Updatedbabel-register@7.0.0-beta.0