Skip to content

Commit 5095ed6

Browse files
committed
Add SOCKET_CLI_VERSION env to spawnCoana
1 parent 964df77 commit 5095ed6

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/utils/coana.mts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ export async function spawnCoana(
1616
extra?: SpawnExtra | undefined,
1717
): Promise<CResult<unknown>> {
1818
const { env: spawnEnv } = { __proto__: null, ...options } as SpawnOptions
19+
const mixinsEnv: Record<string, string> = {
20+
// Lazily access constants.ENV.INLINED_SOCKET_CLI_VERSION.
21+
SOCKET_CLI_VERSION: constants.ENV.INLINED_SOCKET_CLI_VERSION,
22+
}
23+
const defaultApiToken = getDefaultToken()
24+
if (defaultApiToken) {
25+
mixinsEnv['SOCKET_CLI_API_TOKEN'] = defaultApiToken
26+
}
1927
const orgSlugCResult = await getDefaultOrgSlug()
20-
const SOCKET_ORG_SLUG = orgSlugCResult.ok ? orgSlugCResult.data : undefined
21-
const SOCKET_CLI_API_TOKEN = getDefaultToken()
28+
if (orgSlugCResult.ok) {
29+
mixinsEnv['SOCKET_ORG_SLUG'] = orgSlugCResult.data
30+
}
2231
try {
2332
const output = await spawn(
2433
constants.execPath,
@@ -37,8 +46,7 @@ export async function spawnCoana(
3746
...process.env,
3847
// Lazily access constants.processEnv.
3948
...constants.processEnv,
40-
SOCKET_CLI_API_TOKEN,
41-
SOCKET_ORG_SLUG,
49+
...mixinsEnv,
4250
...spawnEnv,
4351
},
4452
},

0 commit comments

Comments
 (0)