Skip to content

Commit ad227c5

Browse files
committed
Fix CLI test runner preload and test-utils fallback for public mirror
1 parent de0954c commit ad227c5

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

cli/bunfig.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
# which is why CI filters those with `find ... ! -name` instead.
1414
preload = [
1515
"../sdk/test/setup-env.ts",
16-
"../test/setup-scm-loader.ts",
1716
"./test/setup-agents-artifact.ts",
1817
]

cli/src/__tests__/test-utils.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,30 @@ function loadCliEnv(): Record<string, string> {
121121

122122
try {
123123
ensureCliEnvDefaults()
124-
// NOTE: Inline require() is used for lazy loading - the env module depends on
125-
// Infisical secrets which may not be available at module load time in test environments
126-
const { env } = require('../../../packages/internal/src/env') as {
127-
env: Record<string, unknown>
128-
}
124+
try {
125+
const { env } = require('../../../packages/internal/src/env') as {
126+
env: Record<string, unknown>
127+
}
129128

130-
cachedEnv = Object.entries(env).reduce<Record<string, string>>(
131-
(acc, [key, value]) => {
132-
if (value !== undefined && value !== null) {
133-
acc[key] = String(value)
134-
}
135-
return acc
136-
},
137-
{},
138-
)
129+
cachedEnv = Object.entries(env).reduce<Record<string, string>>(
130+
(acc, [key, value]) => {
131+
if (value !== undefined && value !== null) {
132+
acc[key] = String(value)
133+
}
134+
return acc
135+
},
136+
{},
137+
)
139138

140-
return cachedEnv
139+
return cachedEnv
140+
} catch {
141+
// Fallback for public mirror where packages/internal is not present
142+
cachedEnv = {
143+
...TEST_CLIENT_ENV_DEFAULTS,
144+
...TEST_SERVER_ENV_DEFAULTS,
145+
}
146+
return cachedEnv
147+
}
141148
} catch (error) {
142149
const message =
143150
error instanceof Error

0 commit comments

Comments
 (0)