mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 16:03:26 +00:00
24 lines
607 B
JavaScript
24 lines
607 B
JavaScript
import { existsSync } from 'node:fs'
|
|
import { win32 } from 'node:path'
|
|
|
|
export function resolveNodeServerNpmInvocation({
|
|
platform = process.platform,
|
|
executablePath = process.execPath,
|
|
pathExists = existsSync
|
|
} = {}) {
|
|
if (platform !== 'win32') {
|
|
return { command: 'npm', prefixArgs: [] }
|
|
}
|
|
const npmCliPath = win32.join(
|
|
win32.dirname(executablePath),
|
|
'node_modules',
|
|
'npm',
|
|
'bin',
|
|
'npm-cli.js'
|
|
)
|
|
if (!pathExists(npmCliPath)) {
|
|
throw new Error(`npm CLI is missing beside Node: ${npmCliPath}`)
|
|
}
|
|
return { command: executablePath, prefixArgs: [npmCliPath] }
|
|
}
|