Add --out-file-extension option to babel-cli (#9144)

* Add --use-file-extension option to babel-cli

* refactor file extension logic

use existing methods from path module

* Rename use-file-extension -> out-file-extension

* add error message if bot keep- and out-file-extension is used

* add test for error when mixing --keep- and --out-file-extension

* poke travis
This commit is contained in:
Sebastian Silbermann
2020-01-10 03:02:52 +01:00
committed by Nicolò Ribaudo
parent c3388ea42f
commit 3af02f63de
11 changed files with 52 additions and 10 deletions

View File

@@ -0,0 +1 @@
arr.map(x => x / DIVIDER);

View File

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

View File

@@ -0,0 +1,12 @@
{
"args": [
"src",
"--out-dir",
"lib",
"--out-file-extension",
".mjs",
"--extensions",
".jsx,.mjs",
"--verbose"
]
}

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x / DIVIDER;
});

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1,3 @@
src/bar.mjs -> lib/bar.mjs
src/foo.jsx -> lib/foo.mjs
Successfully compiled 2 files with Babel.

View File

@@ -0,0 +1,4 @@
{
"args": ["--keep-file-extension", "--out-file-extension", ".mjs"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
--out-file-extension cannot be used with --keep-file-extension