Skip to content

Commit ce192ae

Browse files
Peter HaugeCopilot
andcommitted
fix: use exec instead of execFile for cross-platform npm calls in package-build tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 05627bc commit ce192ae

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

tests/integration/package-build/package-build.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
// Licensed under the MIT license.
33
/// <reference types="node" />
44

5-
import { execFile } from 'node:child_process';
5+
import { exec as execCb } from 'node:child_process';
66
import * as fs from 'node:fs/promises';
77
import * as os from 'node:os';
88
import * as path from 'node:path';
99
import { fileURLToPath } from 'node:url';
1010
import { promisify } from 'node:util';
1111
import { describe, expect, it } from 'vitest';
1212

13-
const exec = promisify(execFile);
14-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
13+
const exec = promisify(execCb);
1514
const currentFileDir = path.dirname(fileURLToPath(import.meta.url));
1615
const repoRoot = path.resolve(currentFileDir, '../../..');
1716

@@ -33,10 +32,14 @@ function normalizePath(filePath: string): string {
3332
}
3433

3534
async function runNpm(args: string[]): Promise<string> {
36-
const result = await exec(npmCommand, args, {
35+
// Use 'npm' with shell so .cmd resolution works on Windows and
36+
// plain 'npm' works on Linux/macOS. Pass args as a single joined string
37+
// to avoid the Node.js v24 DEP0190 deprecation warning about passing
38+
// array args with shell option.
39+
const command = `npm ${args.join(' ')}`;
40+
const result = await exec(command, {
3741
cwd: repoRoot,
3842
timeout: 90_000,
39-
env: process.env,
4043
});
4144

4245
return result.stdout;

0 commit comments

Comments
 (0)