Skip to content

Commit 1c2eaea

Browse files
test: use execSync for cross-platform npx resolution in drift-guard
execFileSync('npx', ...) fails on Windows because npx is npx.cmd and Node's spawn doesn't auto-resolve .cmd extensions without a shell. execSync runs through the shell on every platform.
1 parent a7e94c6 commit 1c2eaea

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

workspace-server/src/__tests__/features/feature-config.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { execFileSync } from 'node:child_process';
7+
import { execSync } from 'node:child_process';
88
import { readFileSync } from 'node:fs';
99
import { join } from 'node:path';
1010

@@ -102,17 +102,13 @@ describe('getAllPossibleScopes (issue #323)', () => {
102102
// fails, the consent screen registration list will drift from
103103
// FEATURE_GROUPS — which is the bug in issue #323.
104104
const repoRoot = join(__dirname, '..', '..', '..', '..');
105-
const output = execFileSync(
106-
'npx',
107-
[
108-
'--no-install',
109-
'ts-node',
110-
'--transpile-only',
111-
'scripts/print-scopes.ts',
112-
],
105+
// execSync (not execFileSync) so Windows can resolve npx.cmd via the
106+
// shell. Tests run on ubuntu/macos/windows.
107+
const output = execSync(
108+
'npx --no-install ts-node --transpile-only scripts/print-scopes.ts',
113109
{ cwd: repoRoot, encoding: 'utf8' },
114110
);
115-
const printed = output.trim().split('\n');
111+
const printed = output.trim().split(/\r?\n/);
116112
expect(printed).toEqual(getAllPossibleScopes());
117113
});
118114

0 commit comments

Comments
 (0)