@babel/cli
Advanced tools
Comparing version 7.7.7 to 7.8.0
@@ -70,2 +70,9 @@ "use strict"; | ||
const FILE_TYPE = Object.freeze({ | ||
NON_COMPILABLE: "NON_COMPILABLE", | ||
COMPILED: "COMPILED", | ||
IGNORED: "IGNORED", | ||
ERR_COMPILATION: "ERR_COMPILATION" | ||
}); | ||
function outputFileSync(filePath, data) { | ||
@@ -97,6 +104,6 @@ (0, _makeDir().sync)(_path().default.dirname(filePath)); | ||
if (!util.isCompilableExtension(relative, cliOptions.extensions)) { | ||
return false; | ||
return FILE_TYPE.NON_COMPILABLE; | ||
} | ||
relative = util.adjustRelative(relative, cliOptions.keepFileExtension); | ||
relative = util.withExtension(relative, cliOptions.keepFileExtension ? _path().default.extname(relative) : cliOptions.outFileExtension); | ||
const dest = getDest(relative, base); | ||
@@ -108,3 +115,3 @@ | ||
}, babelOptions)); | ||
if (!res) return false; | ||
if (!res) return FILE_TYPE.IGNORED; | ||
@@ -125,7 +132,7 @@ if (res.map && babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") { | ||
return true; | ||
return FILE_TYPE.COMPILED; | ||
} catch (err) { | ||
if (cliOptions.watch) { | ||
console.error(err); | ||
return false; | ||
return FILE_TYPE.ERR_COMPILATION; | ||
} | ||
@@ -155,3 +162,3 @@ | ||
if (!written && cliOptions.copyFiles) { | ||
if (cliOptions.copyFiles && written === FILE_TYPE.NON_COMPILABLE || cliOptions.copyIgnored && written === FILE_TYPE.IGNORED) { | ||
const filename = _path().default.relative(base, src); | ||
@@ -164,3 +171,3 @@ | ||
return written; | ||
return written === FILE_TYPE.COMPILED; | ||
}); | ||
@@ -167,0 +174,0 @@ return _handleFile.apply(this, arguments); |
@@ -90,3 +90,3 @@ "use strict"; | ||
_commander().default.option("--minified [true|false]", "Save as many bytes when printing."); | ||
_commander().default.option("--minified", "Save as many bytes when printing. (false by default)"); | ||
@@ -135,2 +135,6 @@ _commander().default.option("--auxiliary-comment-before [string]", "Print a comment before any injected non-user code."); | ||
_commander().default.option("--out-file-extension [string]", "Use a specific extension for the output files"); | ||
_commander().default.option("--copy-ignored", "Include ignored files when copying non-compilable files."); | ||
_commander().default.version(_package.default.version + " (@babel/core " + _core().version + ")"); | ||
@@ -199,2 +203,6 @@ | ||
if (_commander().default.keepFileExtension && _commander().default.outFileExtension) { | ||
errors.push("--out-file-extension cannot be used with --keep-file-extension"); | ||
} | ||
if (errors.length) { | ||
@@ -248,2 +256,3 @@ console.error("babel:"); | ||
keepFileExtension: opts.keepFileExtension, | ||
outFileExtension: opts.outFileExtension, | ||
watch: opts.watch, | ||
@@ -259,3 +268,4 @@ skipInitialBuild: opts.skipInitialBuild, | ||
deleteDirOnStart: opts.deleteDirOnStart, | ||
sourceMapTarget: opts.sourceMapTarget | ||
sourceMapTarget: opts.sourceMapTarget, | ||
copyIgnored: opts.copyIgnored | ||
} | ||
@@ -262,0 +272,0 @@ }; |
@@ -15,3 +15,3 @@ "use strict"; | ||
exports.requireChokidar = requireChokidar; | ||
exports.adjustRelative = adjustRelative; | ||
exports.withExtension = withExtension; | ||
@@ -162,8 +162,5 @@ function _fsReaddirRecursive() { | ||
function adjustRelative(relative, keepFileExtension) { | ||
if (keepFileExtension) { | ||
return relative; | ||
} | ||
return relative.replace(/\.(\w*?)$/, "") + ".js"; | ||
function withExtension(filename, ext = ".js") { | ||
const newBasename = _path().default.basename(filename, _path().default.extname(filename)) + ext; | ||
return _path().default.join(_path().default.dirname(filename), newBasename); | ||
} |
{ | ||
"name": "@babel/cli", | ||
"version": "7.7.7", | ||
"version": "7.8.0", | ||
"description": "Babel command line.", | ||
@@ -8,2 +8,3 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"license": "MIT", | ||
"type": "commonjs", | ||
"publishConfig": { | ||
@@ -39,4 +40,4 @@ "access": "public" | ||
"devDependencies": { | ||
"@babel/core": "^7.7.7", | ||
"@babel/helper-fixtures": "^7.6.3", | ||
"@babel/core": "^7.8.0", | ||
"@babel/helper-fixtures": "^7.8.0", | ||
"rimraf": "^3.0.0" | ||
@@ -48,3 +49,3 @@ }, | ||
}, | ||
"gitHead": "12da0941c898987ae30045a9da90ed5bf58ecaf9" | ||
"gitHead": "2486615a74580283c49475d66067bd7fcab3330e" | ||
} |
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
36019
808