Skip to content

Commit

Permalink
fix(node): support for Node 20.12.2 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Apr 18, 2024
1 parent 8cb971b commit 4958936
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Failsafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,28 @@ export class Failsafe {

private runScript(scriptName: string, arguments_: string[] = []): Promise<ExitCode> {
return new Promise((resolve, reject) => {
const npm = process.platform.startsWith('win32')
const isWindows = process.platform.startsWith('win32');

const npm = isWindows
? `npm.cmd`
: (process.env.npm_execpath ?? `npm`);

const shellOptions = isWindows
? { shell: true }
: {};

const npmArguments = [`run`, scriptName];
if (arguments_.length > 0) {
npmArguments.push('--', ...arguments_);
}

const script = spawn(npm, npmArguments, {
cwd: this.config.cwd,
env: {
'FORCE_COLOR': this.config.isTTY ? '1' : undefined,
...this.env
}
},
...shellOptions,
});

const
Expand Down

0 comments on commit 4958936

Please sign in to comment.