Skip to content

Commit

Permalink
test: use execPath to launch child node processes
Browse files Browse the repository at this point in the history
Using execPath ensures the child processes are the same node binary without depending on PATH.
  • Loading branch information
jbedard authored and angular-robot[bot] committed Nov 28, 2022
1 parent f3fd1e4 commit b8e68eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ export function globalNpm(args: string[], env?: NodeJS.ProcessEnv) {
);
}

return _exec({ silent: true, env }, 'node', [require.resolve('npm'), ...args]);
return _exec({ silent: true, env }, process.execPath, [require.resolve('npm'), ...args]);
}

export function npm(...args: string[]) {
return _exec({}, 'npm', args);
}

export function node(...args: string[]) {
return _exec({}, 'node', args);
return _exec({}, process.execPath, args);
}

export function git(...args: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function prepareProjectForE2e(name: string) {
// Often fails the first time so attempt twice if necessary.
const runWebdriverUpdate = () =>
exec(
'node',
process.execPath,
'node_modules/protractor/bin/webdriver-manager',
'update',
'--standalone',
Expand Down
12 changes: 8 additions & 4 deletions tests/legacy-cli/e2e/utils/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export async function createNpmRegistry(
configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
await writeFile(join(registryPath, 'verdaccio.yaml'), configContent);

return spawn('node', [require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'], {
cwd: registryPath,
stdio: 'inherit',
});
return spawn(
process.execPath,
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
{
cwd: registryPath,
stdio: 'inherit',
},
);
}

// Token was generated using `echo -n 'testing:s3cret' | openssl base64`.
Expand Down

0 comments on commit b8e68eb

Please sign in to comment.