Skip to content

Commit 919cf55

Browse files
feat: 添加开发者默认开启的 feature
1 parent 4337b82 commit 919cf55

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

scripts/dev.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ const defineArgs = Object.entries(defines).flatMap(([k, v]) => [
1414
]);
1515

1616
// Bun --feature flags: enable feature() gates at runtime.
17-
// Any env var matching FEATURE_<NAME>=1 will enable that feature.
18-
// e.g. FEATURE_TRANSCRIPT_CLASSIFIER=1 bun run dev
19-
const featureArgs: string[] = Object.entries(process.env)
17+
// Default features enabled in dev mode.
18+
const DEFAULT_FEATURES = ["BUDDY", "TRANSCRIPT_CLASSIFIER"];
19+
20+
// Any env var matching FEATURE_<NAME>=1 will also enable that feature.
21+
// e.g. FEATURE_PROACTIVE=1 bun run dev
22+
const envFeatures = Object.entries(process.env)
2023
.filter(([k]) => k.startsWith("FEATURE_"))
21-
.flatMap(([k]) => {
22-
const name = k.replace("FEATURE_", "");
23-
return ["--feature", name];
24-
});
24+
.map(([k]) => k.replace("FEATURE_", ""));
25+
26+
const allFeatures = [...new Set([...DEFAULT_FEATURES, ...envFeatures])];
27+
const featureArgs = allFeatures.flatMap((name) => ["--feature", name]);
2528

2629
const result = Bun.spawnSync(
2730
["bun", "run", ...defineArgs, ...featureArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],

0 commit comments

Comments
 (0)