Skip to content

Commit 5d8b9cf

Browse files
committed
fix: properly quote paths
1 parent ff604ec commit 5d8b9cf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

scripts/postinstall.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function main() {
5252
// https://github.com/eggjs/egg-ts-helper/pull/104
5353
process.env.ETS_SCRIPT_FRAMEWORK = frameworkPackageName;
5454
console.log('[@eggjs/bin/postinstall] run %s on %s', etsBinFile, npmRunRoot);
55-
runScript(`node ${etsBinFile}`);
55+
runScript(`node "${etsBinFile}"`);
5656
}
5757
}
5858
}

src/baseCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
261261
paths: findPaths,
262262
});
263263
debug('run ets first: %o', etsBin);
264-
await runScript(`node ${etsBin}`);
264+
await runScript(`node "${etsBin}"`);
265265
}
266266

267267
if (this.pkgEgg.revert) {
@@ -327,9 +327,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
327327

328328
protected formatImportModule(modulePath: string) {
329329
if (this.isESM) {
330-
return `--import ${pathToFileURL(modulePath).href}`;
330+
return `--import "${pathToFileURL(modulePath).href}"`;
331331
}
332-
return `--require ${modulePath}`;
332+
return `--require "${modulePath}"`;
333333
}
334334

335335
protected addNodeOptions(options: string) {

src/commands/dev.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ export default class Dev<T extends typeof Dev> extends BaseCommand<T> {
4444
const requires = await this.formatRequires();
4545
const execArgv: string[] = [];
4646
for (const r of requires) {
47-
const imports = this.formatImportModule(r).split(' ');
48-
execArgv.push(...imports);
47+
const module = this.formatImportModule(r);
48+
const splitIndex = module.indexOf(' ');
49+
if (splitIndex !== -1) {
50+
// --require "path to module"
51+
execArgv.push(module.slice(0, splitIndex), module.slice(splitIndex + 2, -1));
52+
}
4953
}
5054
await this.forkNode(serverBin, args, { execArgv });
5155
}

0 commit comments

Comments
 (0)