test: use execPath to launch child node processes

Using execPath ensures the child processes are the same node binary without depending on PATH.
This commit is contained in:
Jason Bedard 2022-08-29 20:12:23 -07:00 committed by angular-robot[bot]
parent f3fd1e4ed8
commit b8e68eb28a
3 changed files with 11 additions and 7 deletions

View File

@ -345,7 +345,7 @@ 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[]) { export function npm(...args: string[]) {
@ -353,7 +353,7 @@ export function npm(...args: string[]) {
} }
export function node(...args: string[]) { export function node(...args: string[]) {
return _exec({}, 'node', args); return _exec({}, process.execPath, args);
} }
export function git(...args: string[]) { export function git(...args: string[]) {

View File

@ -67,7 +67,7 @@ export async function prepareProjectForE2e(name: string) {
// Often fails the first time so attempt twice if necessary. // Often fails the first time so attempt twice if necessary.
const runWebdriverUpdate = () => const runWebdriverUpdate = () =>
exec( exec(
'node', process.execPath,
'node_modules/protractor/bin/webdriver-manager', 'node_modules/protractor/bin/webdriver-manager',
'update', 'update',
'--standalone', '--standalone',

View File

@ -19,10 +19,14 @@ export async function createNpmRegistry(
configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort)); configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
await writeFile(join(registryPath, 'verdaccio.yaml'), configContent); await writeFile(join(registryPath, 'verdaccio.yaml'), configContent);
return spawn('node', [require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'], { return spawn(
cwd: registryPath, process.execPath,
stdio: 'inherit', [require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
}); {
cwd: registryPath,
stdio: 'inherit',
},
);
} }
// Token was generated using `echo -n 'testing:s3cret' | openssl base64`. // Token was generated using `echo -n 'testing:s3cret' | openssl base64`.