11/** @fileoverview Coana CLI spawn utilities for Socket CLI. */
22
3- import { createRequire } from 'node:module'
4-
53import { spawn } from '@socketsecurity/registry/lib/spawn'
64
75import { getDefaultOrgSlug } from '../commands/ci/fetch-default-org-slug.mts'
@@ -10,12 +8,10 @@ import { getErrorCause } from './errors.mts'
108import { getDefaultApiToken , getDefaultProxyUrl } from './sdk.mts'
119import { runShadowCommand } from './shadow-runner.mts'
1210
13- import type { ShadowBinOptions , ShadowBinResult } from '../shadow/npm-base.mts'
11+ import type { ShadowBinOptions } from '../shadow/npm-base.mts'
1412import type { CResult } from '../types.mts'
1513import type { SpawnExtra } from '@socketsecurity/registry/lib/spawn'
1614
17- const require = createRequire ( import . meta. url )
18-
1915export type CoanaSpawnOptions = ShadowBinOptions & {
2016 agent ?: 'npm' | 'pnpm' | 'yarn' | undefined
2117}
@@ -101,8 +97,11 @@ export async function spawnCoana(
10197
10298 const result = await runShadowCommand ( packageSpec , args , {
10399 agent,
104- cwd : shadowOptions . cwd ,
105- env : finalEnv ,
100+ cwd :
101+ typeof shadowOptions . cwd === 'string'
102+ ? shadowOptions . cwd
103+ : shadowOptions . cwd ?. toString ( ) ,
104+ env : finalEnv as Record < string , string > ,
106105 ipc,
107106 stdio : spawnExtra ?. [ 'stdio' ] || 'inherit' ,
108107 } )
0 commit comments