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

@@ -1,7 +1,7 @@
import path from "path";
import fs from "fs";
import os from "os";
import { sync as mkdirpSync } from "mkdirp";
import { sync as makeDirSync } from "make-dir";
import * as babel from "@babel/core";
import findCacheDir from "find-cache-dir";
@@ -39,7 +39,7 @@ export function save() {
}
try {
mkdirpSync(path.dirname(FILENAME));
makeDirSync(path.dirname(FILENAME));
fs.writeFileSync(FILENAME, serialised);
} catch (e) {
switch (e.code) {