Make dir for babel --out-file (#8622)

* Make dir for babel --out-file

Currently there's unexpected regression after upgrade from babel 6.
On creating file with any depth like dist/index.js the error about
not existing directory is thrown.

In this diff I modified babel-cli to create deep directory for out-file
command.

I also replaced `mkdirp` with more supported `make-dir` package which
also have official promise support.

* Fix test
This commit is contained in:
Bogdan Chadkin
2019-10-29 19:29:45 +02:00
committed by Nicolò Ribaudo
parent 4e5ac1fd5c
commit be0fcaaf49
8 changed files with 18 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync";
import { sync as mkdirpSync } from "mkdirp";
import { sync as makeDirSync } from "make-dir";
import slash from "slash";
import path from "path";
import fs from "fs";
@@ -122,7 +122,7 @@ export default async function({
util.deleteDir(cliOptions.outDir);
}
mkdirpSync(cliOptions.outDir);
makeDirSync(cliOptions.outDir);
let compiledFiles = 0;
for (const filename of cliOptions.filenames) {

View File

@@ -4,6 +4,7 @@ import convertSourceMap from "convert-source-map";
import defaults from "lodash/defaults";
import sourceMap from "source-map";
import slash from "slash";
import { sync as makeDirSync } from "make-dir";
import path from "path";
import fs from "fs";
@@ -89,6 +90,8 @@ export default async function({
const result = buildResult(fileResults);
if (cliOptions.outFile) {
makeDirSync(path.dirname(cliOptions.outFile));
// we've requested for a sourcemap to be written to disk
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
const mapLoc = cliOptions.outFile + ".map";