@@ -8,6 +8,7 @@ import { join } from 'node:path'
88import * as v from 'valibot'
99import { PackageNameSchema , UsernameSchema , OrgNameSchema , ScopeTeamSchema } from './schemas.ts'
1010import { logCommand , logSuccess , logError , logDebug } from './logger.ts'
11+ import { resolveNpmProcessCommand } from './npm-process.ts'
1112
1213const execFileAsync = promisify ( execFile )
1314export const NPM_REGISTRY_URL = 'https://registry.npmjs.org/'
@@ -333,13 +334,10 @@ async function execNpm(args: string[], options: ExecNpmOptions = {}): Promise<Np
333334
334335 try {
335336 logDebug ( 'Executing npm command:' , { command : 'npm' , args : npmArgs } )
336- // Use execFile instead of exec to avoid shell injection vulnerabilities
337- // On Windows, shell: true is required to execute .cmd files (like npm.cmd)
338- // On Unix, we keep it false for better security and performance
339- const { stdout, stderr } = await execFileAsync ( 'npm' , npmArgs , {
337+ const { command, args : processArgs } = resolveNpmProcessCommand ( npmArgs )
338+ const { stdout, stderr } = await execFileAsync ( command , processArgs , {
340339 timeout : 60000 ,
341340 env : createNpmEnv ( ) ,
342- shell : process . platform === 'win32' ,
343341 } )
344342
345343 logDebug ( 'Command succeeded:' , { stdout, stderr } )
@@ -610,11 +608,11 @@ export async function packageInit(
610608 logCommand ( `${ displayCmd } (in temp dir for ${ name } )` )
611609
612610 try {
613- const { stdout, stderr } = await execFileAsync ( 'npm' , npmArgs , {
611+ const { command, args : processArgs } = resolveNpmProcessCommand ( npmArgs )
612+ const { stdout, stderr } = await execFileAsync ( command , processArgs , {
614613 timeout : 60000 ,
615614 cwd : tempDir . path ,
616615 env : createNpmEnv ( ) ,
617- shell : process . platform === 'win32' ,
618616 } )
619617
620618 logSuccess ( `Published ${ name } @0.0.0` )
0 commit comments