fix: suppress experimental sqlite warning at startup
This commit is contained in:
27
src/entry.ts
27
src/entry.ts
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
import { spawnSync } from "node:child_process";
|
||||
import process from "node:process";
|
||||
|
||||
import { applyCliProfileEnv, parseCliProfileArgs } from "./cli/profile.js";
|
||||
@@ -8,6 +9,32 @@ if (process.argv.includes("--no-color")) {
|
||||
process.env.FORCE_COLOR = "0";
|
||||
}
|
||||
|
||||
const EXPERIMENTAL_WARNING_FLAG = "--disable-warning=ExperimentalWarning";
|
||||
|
||||
function hasExperimentalWarningSuppressed(nodeOptions: string): boolean {
|
||||
if (!nodeOptions) return false;
|
||||
return (
|
||||
nodeOptions.includes(EXPERIMENTAL_WARNING_FLAG) ||
|
||||
nodeOptions.includes("--no-warnings")
|
||||
);
|
||||
}
|
||||
|
||||
function ensureExperimentalWarningSuppressed(): void {
|
||||
if (process.env.CLAWDBOT_NODE_OPTIONS_READY === "1") return;
|
||||
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
||||
if (hasExperimentalWarningSuppressed(nodeOptions)) return;
|
||||
process.env.CLAWDBOT_NODE_OPTIONS_READY = "1";
|
||||
process.env.NODE_OPTIONS = `${nodeOptions} ${EXPERIMENTAL_WARNING_FLAG}`.trim();
|
||||
const result = spawnSync(process.execPath, process.argv.slice(1), {
|
||||
stdio: "inherit",
|
||||
env: process.env,
|
||||
});
|
||||
if (result.signal) process.exit(1);
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
|
||||
ensureExperimentalWarningSuppressed();
|
||||
|
||||
const parsed = parseCliProfileArgs(process.argv);
|
||||
if (!parsed.ok) {
|
||||
// Keep it simple; Commander will handle rich help/errors after we strip flags.
|
||||
|
||||
Reference in New Issue
Block a user