From 10705684c8cda8cc7cec7a1ab63c8f0f0b574349 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 26 Apr 2019 10:08:04 +0200 Subject: [PATCH] test: fix api guardian tests on windows when node_modules are not installed (#30105) When the workspace node_modules are not installed outside of bazel context the api guardian tests fails because the tree artifacts files are not symlinked in windows. We need to pass the node module location in the node_path PR Close #30105 --- tools/ts-api-guardian/test/cli_e2e_test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ts-api-guardian/test/cli_e2e_test.ts b/tools/ts-api-guardian/test/cli_e2e_test.ts index 3c540b7bc2..b22b4f837c 100644 --- a/tools/ts-api-guardian/test/cli_e2e_test.ts +++ b/tools/ts-api-guardian/test/cli_e2e_test.ts @@ -124,7 +124,11 @@ function execute(args: string[]): {stdout: string, stderr: string, status: numbe // We need to determine the directory that includes the `ts-api-guardian` npm_package that // will be used to spawn the CLI binary. This is a workaround because technically we shouldn't // spawn a child process that doesn't have the custom NodeJS module resolution for Bazel. - const nodePath = path.join(path.dirname(require.resolve('../lib/cli.js')), '../'); + const nodePath = [ + path.join(require.resolve('npm/node_modules/chalk/package.json'), '../../'), + path.join(require.resolve('../lib/cli.js'), '../../'), + ].join(process.platform === 'win32' ? ';' : ':'); + const output = child_process.spawnSync(process.execPath, [BINARY_PATH, ...args], { env: { 'NODE_PATH': nodePath,