Skip to content

Commit 59eec53

Browse files
committed
Recursively create modules directory
1 parent 75c8bd6 commit 59eec53

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/server/src/modules.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ declare var __non_webpack_require__: typeof require;
88
* Handling of native modules within the CLI
99
*/
1010
export const setup = (dataDirectory: string): void => {
11-
try {
12-
fs.mkdirSync(path.join(dataDirectory, "modules"));
13-
} catch (ex) {
14-
if (ex.code !== "EEXIST") {
15-
throw ex;
11+
path.resolve(dataDirectory, "modules").split(path.sep).reduce((parentDir, childDir) => {
12+
const currentDir = path.join(parentDir, childDir);
13+
try {
14+
fs.mkdirSync(currentDir);
15+
} catch (ex) {
16+
if (ex.code !== "EEXIST") {
17+
throw ex;
18+
}
1619
}
17-
}
20+
21+
return currentDir;
22+
}, path.sep);
1823

1924
const unpackModule = (moduleName: string): void => {
2025
const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/modules", moduleName + ".node");

0 commit comments

Comments
 (0)