mirror of
https://github.com/HeyPuter/puter.git
synced 2026-10-03 02:18:06 +00:00
* fix(tools): spawn npm.cmd through a shell on Windows * fix(tools): join the npm command line on Windows to avoid DEP0190 Passing args alongside shell: true warns on Node 24. Test the spawn tuple as data and run a real npm spawn instead of mocking child_process. --------- Co-authored-by: Daniel Salazar <daniel.salazar@puter.com>
22 lines
769 B
JavaScript
22 lines
769 B
JavaScript
// Shared helper for spawning npm from the repo's tools/ scripts.
|
|
//
|
|
// On Windows `npm` resolves to the `npm.cmd` batch shim, which Node refuses
|
|
// to spawn without a shell (`spawn EINVAL`). Node also warns when args are
|
|
// passed alongside `shell: true` (DEP0190), so the command line is joined
|
|
// here; args must be plain words that need no quoting.
|
|
|
|
import { spawn } from 'node:child_process';
|
|
|
|
/** `[command, args, options]` for `spawn`. */
|
|
export const npmSpawnArgs = (
|
|
args,
|
|
options = {},
|
|
platform = process.platform,
|
|
) =>
|
|
platform === 'win32'
|
|
? [['npm.cmd', ...args].join(' '), [], { ...options, shell: true }]
|
|
: ['npm', args, options];
|
|
|
|
export const spawnNpm = (args, options = {}) =>
|
|
spawn(...npmSpawnArgs(args, options));
|