Test babel-cli --source-maps and errors (#5377)
This commit is contained in:
parent
9aec4ad159
commit
dad55ef1d6
@ -162,20 +162,20 @@ export default function parseArgv(args: Array<string>) {
|
|||||||
|
|
||||||
filenames.forEach(function(filename) {
|
filenames.forEach(function(filename) {
|
||||||
if (!fs.existsSync(filename)) {
|
if (!fs.existsSync(filename)) {
|
||||||
errors.push(filename + " doesn't exist");
|
errors.push(filename + " does not exist");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (commander.outDir && !filenames.length) {
|
if (commander.outDir && !filenames.length) {
|
||||||
errors.push("filenames required for --out-dir");
|
errors.push("--out-dir requires filenames");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commander.outFile && commander.outDir) {
|
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) {
|
if (commander.relative && !commander.outDir) {
|
||||||
errors.push("output directory required for --relative");
|
errors.push("--relative requires --out-dir usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commander.watch) {
|
if (commander.watch) {
|
||||||
@ -207,7 +207,10 @@ export default function parseArgv(args: Array<string>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
console.error(errors.join(". "));
|
console.error("babel:");
|
||||||
|
errors.forEach(function (e) {
|
||||||
|
console.error(" " + e);
|
||||||
|
});
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"args": ["--source-maps", "--out-file", "test.js"]
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"args": ["--source-maps", "inline"]
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
arr.map(function (x) {
|
|
||||||
return x * x;
|
|
||||||
});
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBRyxDQUFDLEdBQUcsQ0FBQyxVQUFBLENBQUM7U0FBSSxDQUFDLEdBQUcsQ0FBQztDQUFBLENBQUMsQ0FBQyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIHgpOyJdfQ==
|
|
||||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Test {
|
||||||
|
|
||||||
|
}
|
||||||
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/foo.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/foo.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["src", "--out-dir", "lib", "--out-file", "compiled.js"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
--out-file and --out-dir cannot be used together
|
||||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--out-dir", "lib"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
--out-dir requires filenames
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Test {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
3
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["src", "--skip-initial-build", "--out-dir", "lib"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
--skip-initial-build requires --watch
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Test {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
3
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["src", "--watch"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
--watch requires --out-file or --out-dir
|
||||||
@ -1 +1 @@
|
|||||||
filenames required for --out-dir
|
--out-dir requires filenames
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
cannot have --out-file and --out-dir
|
--out-file and --out-dir cannot be used together
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"args": ["--relative"],
|
"args": ["--relative", "--no-babelrc"],
|
||||||
"stderrContains": true
|
"stderrContains": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
output directory required for --relative
|
--relative requires --out-dir usage
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
foo.json doesn't exist
|
foo.json does not exist
|
||||||
|
|||||||
1
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/in-files/script.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/in-files/script.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
3
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--watch", "--out-file", "out.js", "--no-babelrc"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
--watch requires filenames
|
||||||
3
packages/babel-cli/test/fixtures/babel/filename does not exist/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/filename does not exist/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["index.js"]
|
||||||
|
}
|
||||||
2
packages/babel-cli/test/fixtures/babel/filename does not exist/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/filename does not exist/stderr.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
babel:
|
||||||
|
index.js does not exist
|
||||||
3
packages/babel-cli/test/fixtures/babel/stdin --out-file --source-maps/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --out-file --source-maps/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--source-maps", "--out-file", "test.js", "--no-babelrc"]
|
||||||
|
}
|
||||||
@ -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);"]}
|
||||||
3
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--source-maps", "inline", "--no-babelrc"]
|
||||||
|
}
|
||||||
8
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/stdout.txt
vendored
Normal file
8
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/stdout.txt
vendored
Normal 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==
|
||||||
Loading…
x
Reference in New Issue
Block a user