Skip to content

Commit d56cc6a

Browse files
committed
Fix coana-spawn cwd and env type handling
1 parent 439613b commit d56cc6a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/utils/coana-spawn.mts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/** @fileoverview Coana CLI spawn utilities for Socket CLI. */
22

3-
import { createRequire } from 'node:module'
4-
53
import { spawn } from '@socketsecurity/registry/lib/spawn'
64

75
import { getDefaultOrgSlug } from '../commands/ci/fetch-default-org-slug.mts'
@@ -10,12 +8,10 @@ import { getErrorCause } from './errors.mts'
108
import { getDefaultApiToken, getDefaultProxyUrl } from './sdk.mts'
119
import { 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'
1412
import type { CResult } from '../types.mts'
1513
import type { SpawnExtra } from '@socketsecurity/registry/lib/spawn'
1614

17-
const require = createRequire(import.meta.url)
18-
1915
export 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

Comments
 (0)