@creditkarma/thrift-parser
Version:
A parser for Thrift written in TypeScript
34 lines • 915 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const os = require("os");
function rootDir() {
if (os.platform() === 'win32') {
return process.cwd().split(path.sep)[0];
}
else {
return '/';
}
}
function createPath(parts, soFar) {
const current = path.join(soFar, parts[0]);
if (!fs.existsSync(current)) {
fs.mkdirSync(current);
}
if (parts.length > 1) {
createPath(parts.slice(1), current);
}
}
function mkdir(dirPath) {
const parts = dirPath.split(path.sep).filter((val) => val !== '');
// Check for absolute path
if (parts.length > 0 && path.isAbsolute(dirPath)) {
createPath(parts, rootDir());
}
else if (parts.length > 0) {
createPath(parts, process.cwd());
}
}
exports.mkdir = mkdir;
//# sourceMappingURL=mkdir.js.map