Skip to content

Commit 541cd0e

Browse files
committed
fix(dlx): support Coana CLI binary execution via SOCKET_CLI_COANA_LOCAL_PATH
Update SOCKET_CLI_COANA_LOCAL_PATH to support the Coana CLI binary. Check if local path is a binary (.js/.mjs extension check) and execute directly instead of always using node. Based on #917 Ported from v1.x commit 9d0164c
1 parent 25fcb52 commit 541cd0e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/cli/src/utils/dlx/spawn.mts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,30 @@ export async function spawnCoanaDlx(
145145

146146
// Use local Coana CLI if available.
147147
if (resolution.type === 'local') {
148+
const isBinary =
149+
!resolution.path.endsWith('.js') && !resolution.path.endsWith('.mjs')
150+
148151
const finalEnv = {
149152
...process.env,
150153
...mixinsEnv,
151154
...spawnEnv,
152155
}
153-
const spawnPromise = spawnNode([resolution.path, ...args], {
156+
157+
const spawnArgs = isBinary ? args : [resolution.path, ...args]
158+
const spawnCommand = isBinary ? resolution.path : 'node'
159+
160+
const { spawn } = await import('@socketsecurity/lib/spawn')
161+
const spawnPromise = spawn(spawnCommand, spawnArgs, {
154162
...dlxOptions,
155163
env: finalEnv,
156164
stdio: spawnExtra?.['stdio'] || 'inherit',
157165
})
158166

167+
const output = await spawnPromise
168+
159169
return {
160170
ok: true,
161-
data: spawnPromise.process.stdout?.toString() ?? '',
171+
data: output.stdout?.toString() ?? '',
162172
}
163173
}
164174

0 commit comments

Comments
 (0)