Test babel-cli --source-maps and errors (#5377)

This commit is contained in:
Aaron Ang 2017-02-25 00:13:22 -08:00 committed by Logan Smyth
parent 9aec4ad159
commit dad55ef1d6
35 changed files with 71 additions and 24 deletions

View File

@ -162,20 +162,20 @@ export default function parseArgv(args: Array<string>) {
filenames.forEach(function(filename) {
if (!fs.existsSync(filename)) {
errors.push(filename + " doesn't exist");
errors.push(filename + " does not exist");
}
});
if (commander.outDir && !filenames.length) {
errors.push("filenames required for --out-dir");
errors.push("--out-dir requires filenames");
}
if (commander.outFile && commander.outDir) {
errors.push("cannot have --out-file and --out-dir");
errors.push("--out-file and --out-dir cannot be used together");
}
if (commander.relative && !commander.outDir) {
errors.push("output directory required for --relative");
errors.push("--relative requires --out-dir usage");
}
if (commander.watch) {
@ -207,7 +207,10 @@ export default function parseArgv(args: Array<string>) {
}
if (errors.length) {
console.error(errors.join(". "));
console.error("babel:");
errors.forEach(function (e) {
console.error(" " + e);
});
process.exit(2);
}

View File

@ -1,3 +0,0 @@
{
"args": ["--source-maps", "--out-file", "test.js"]
}

View File

@ -1,3 +0,0 @@
{
"args": ["--source-maps", "inline"]
}

View File

@ -1,7 +0,0 @@
"use strict";
arr.map(function (x) {
return x * x;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBRyxDQUFDLEdBQUcsQ0FBQyxVQUFBLENBQUM7U0FBSSxDQUFDLEdBQUcsQ0FBQztDQUFBLENBQUMsQ0FBQyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIHgpOyJdfQ==

View File

@ -0,0 +1,3 @@
class Test {
}

View File

@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@ -0,0 +1,3 @@
{
"args": ["src", "--out-dir", "lib", "--out-file", "compiled.js"]
}

View File

@ -0,0 +1,2 @@
babel:
--out-file and --out-dir cannot be used together

View File

@ -0,0 +1,3 @@
{
"args": ["--out-dir", "lib"]
}

View File

@ -0,0 +1,2 @@
babel:
--out-dir requires filenames

View File

@ -0,0 +1,3 @@
class Test {
}

View File

@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@ -0,0 +1,3 @@
{
"args": ["src", "--skip-initial-build", "--out-dir", "lib"]
}

View File

@ -0,0 +1,2 @@
babel:
--skip-initial-build requires --watch

View File

@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@ -0,0 +1,3 @@
{
"args": ["src", "--watch"]
}

View File

@ -0,0 +1,2 @@
babel:
--watch requires --out-file or --out-dir

View File

@ -1 +1 @@
filenames required for --out-dir
--out-dir requires filenames

View File

@ -1 +1 @@
cannot have --out-file and --out-dir
--out-file and --out-dir cannot be used together

View File

@ -1,4 +1,4 @@
{
"args": ["--relative"],
"args": ["--relative", "--no-babelrc"],
"stderrContains": true
}

View File

@ -1 +1 @@
output directory required for --relative
--relative requires --out-dir usage

View File

@ -1 +1 @@
foo.json doesn't exist
foo.json does not exist

View File

@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@ -0,0 +1,3 @@
{
"args": ["--watch", "--out-file", "out.js", "--no-babelrc"]
}

View File

@ -0,0 +1,2 @@
babel:
--watch requires filenames

View File

@ -0,0 +1,3 @@
{
"args": ["index.js"]
}

View File

@ -0,0 +1,2 @@
babel:
index.js does not exist

View File

@ -0,0 +1,3 @@
{
"args": ["--source-maps", "--out-file", "test.js", "--no-babelrc"]
}

View File

@ -1 +1 @@
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,CAAC;CAAA,CAAC,CAAC","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAJ,CAAQ,UAAA,CAAC;AAAA,SAAI,CAAC,GAAG,CAAR;AAAA,CAAT","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}

View File

@ -0,0 +1,3 @@
{
"args": ["--source-maps", "inline", "--no-babelrc"]
}

View File

@ -0,0 +1,8 @@
"use strict";
arr.map(function (x) {
return x * x;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbImFyciIsIm1hcCIsIngiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7QUFBQSxTQUFJQSxDQUFDLEdBQUdBLENBQVI7QUFBQSxDQUFUIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiB4KTsiXX0=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzdGRvdXQifQ==