Archived
1
0

Recursively create modules directory

This commit is contained in:
Asher 2019-02-22 18:42:59 -06:00
parent 75c8bd62f1
commit 59eec534b6
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC

View File

@ -8,13 +8,18 @@ declare var __non_webpack_require__: typeof require;
* Handling of native modules within the CLI * Handling of native modules within the CLI
*/ */
export const setup = (dataDirectory: string): void => { export const setup = (dataDirectory: string): void => {
try { path.resolve(dataDirectory, "modules").split(path.sep).reduce((parentDir, childDir) => {
fs.mkdirSync(path.join(dataDirectory, "modules")); const currentDir = path.join(parentDir, childDir);
} catch (ex) { try {
if (ex.code !== "EEXIST") { fs.mkdirSync(currentDir);
throw ex; } catch (ex) {
if (ex.code !== "EEXIST") {
throw ex;
}
} }
}
return currentDir;
}, path.sep);
const unpackModule = (moduleName: string): void => { const unpackModule = (moduleName: string): void => {
const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/modules", moduleName + ".node"); const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/modules", moduleName + ".node");