feat: 添加开发者默认开启的 feature
This commit is contained in:
parent
4337b82e6c
commit
919cf55591
@ -14,14 +14,17 @@ const defineArgs = Object.entries(defines).flatMap(([k, v]) => [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Bun --feature flags: enable feature() gates at runtime.
|
// Bun --feature flags: enable feature() gates at runtime.
|
||||||
// Any env var matching FEATURE_<NAME>=1 will enable that feature.
|
// Default features enabled in dev mode.
|
||||||
// e.g. FEATURE_TRANSCRIPT_CLASSIFIER=1 bun run dev
|
const DEFAULT_FEATURES = ["BUDDY", "TRANSCRIPT_CLASSIFIER"];
|
||||||
const featureArgs: string[] = Object.entries(process.env)
|
|
||||||
|
// Any env var matching FEATURE_<NAME>=1 will also enable that feature.
|
||||||
|
// e.g. FEATURE_PROACTIVE=1 bun run dev
|
||||||
|
const envFeatures = Object.entries(process.env)
|
||||||
.filter(([k]) => k.startsWith("FEATURE_"))
|
.filter(([k]) => k.startsWith("FEATURE_"))
|
||||||
.flatMap(([k]) => {
|
.map(([k]) => k.replace("FEATURE_", ""));
|
||||||
const name = k.replace("FEATURE_", "");
|
|
||||||
return ["--feature", name];
|
const allFeatures = [...new Set([...DEFAULT_FEATURES, ...envFeatures])];
|
||||||
});
|
const featureArgs = allFeatures.flatMap((name) => ["--feature", name]);
|
||||||
|
|
||||||
const result = Bun.spawnSync(
|
const result = Bun.spawnSync(
|
||||||
["bun", "run", ...defineArgs, ...featureArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],
|
["bun", "run", ...defineArgs, ...featureArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user