Skip to content

Commit bca2f51

Browse files
ksroda-saclaude
andcommitted
Address Copilot review: fix redundant lookup and validate env vars
- Extract run_command to local variable to avoid redundant lookup - Add validation for missing env vars in vite.config.ts with clear error Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2a2fa25 commit bca2f51

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

samples/react/login-pkce/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const exposedEnvVars = [
1111

1212
export default defineConfig(({ mode }) => {
1313
const env = loadEnv(mode, process.cwd(), "");
14+
const missing = exposedEnvVars.filter((key) => !env[key]);
15+
if (missing.length > 0) {
16+
throw new Error(
17+
`Missing required env vars: ${missing.join(", ")}. Copy .env.example to .env and fill in the values.`,
18+
);
19+
}
1420
return {
1521
plugins: [react()],
1622
define: Object.fromEntries(

scripts/extract-snippets.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,15 @@ async function main() {
206206
snippets[scenarioId] = {};
207207
}
208208

209+
const runCommand = manifest.scenarios[scenarioId]?.run_command;
209210
snippets[scenarioId][fw] = {
210211
steps: allSteps,
211212
framework: fw,
212213
lib: manifest.lib,
213214
lib_version: getLibVersion(scenarioDir, frameworkDir),
214215
install: getInstallCommand(scenarioDir),
215216
repo_path: `samples/${path.relative(SAMPLES, scenarioDir)}`,
216-
...(manifest.scenarios[scenarioId]?.run_command && {
217-
run_command: manifest.scenarios[scenarioId].run_command,
218-
}),
217+
...(runCommand ? { run_command: runCommand } : {}),
219218
};
220219
}
221220
}

0 commit comments

Comments
 (0)