Dawn/tools/utils/file.js
2021-10-17 11:08:40 -07:00

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
}