Utils example

This commit is contained in:
2021-10-17 11:08:40 -07:00
parent 12df54b344
commit c2bbaad5dd
12 changed files with 272 additions and 58 deletions

19
tools/utils/file.js Normal file
View File

@ -0,0 +1,19 @@
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
}