fix mkdirp
This commit is contained in:
parent
787c77dae6
commit
3562483587
1 changed files with 3 additions and 28 deletions
|
@ -1,37 +1,12 @@
|
||||||
import mkdirp from 'mkdirp';
|
import mkdirp from 'mkdirp';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import deasync from 'deasync';
|
|
||||||
|
|
||||||
const mkdirParentsPath = (filePath) => new Promise(async (resolve, reject) =>{
|
|
||||||
const folderFileIn = "/" + _.initial(filePath.split("/")).join("/");
|
|
||||||
await mkdirp(folderFileIn).catch(reject);
|
|
||||||
resolve(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
const mkdirParentsPathSync = (filePath) => {
|
const mkdirParentsPathSync = (filePath) => {
|
||||||
let done = false;
|
const folderFileIn = ("/" + _.initial(filePath.split("/")).join("/")).replace(/\/\//g, "/");
|
||||||
let err;
|
mkdirp.sync(folderFileIn)
|
||||||
let result;
|
|
||||||
|
|
||||||
mkdirParentsPath(filePath).then(res => {
|
|
||||||
result = res;
|
|
||||||
done = true;
|
|
||||||
})
|
|
||||||
.catch(e => { // eslint-disable-line no-unused-vars
|
|
||||||
err = e;
|
|
||||||
done = true; // eslint-disable-line no-unused-vars });
|
|
||||||
});
|
|
||||||
deasync.loopWhile(function(){return !done;});
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
} else {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
mkdirParentsPath as default,
|
mkdirParentsPathSync as default,
|
||||||
mkdirParentsPath,
|
|
||||||
mkdirParentsPathSync
|
mkdirParentsPathSync
|
||||||
}
|
}
|
Loading…
Reference in a new issue