molstar
Version:
A comprehensive macromolecular library.
23 lines (22 loc) • 670 B
JavaScript
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeDir = makeDir;
const tslib_1 = require("tslib");
const fs = tslib_1.__importStar(require("fs"));
function makeDir(path, root) {
const dirs = path.split(/\/|\\/g), dir = dirs.shift();
root = (root || '') + dir + '/';
try {
fs.mkdirSync(root);
}
catch (e) {
if (!fs.statSync(root).isDirectory())
throw new Error(e);
}
return !dirs.length || makeDir(dirs.join('/'), root);
}
;