19 lines
392 B
JavaScript
19 lines
392 B
JavaScript
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const mkdirp = dir => {
|
|
const resolved = path.resolve(dir);
|
|
const resolvedDir = path.dirname(resolved);
|
|
const bits = resolvedDir.split(path.sep);
|
|
let running = '';
|
|
|
|
bits.forEach(bit => {
|
|
running += bit;
|
|
if(!fs.existsSync(running)) fs.mkdirSync(running);
|
|
running += path.sep;
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
mkdirp
|
|
} |