MCPcopy Create free account
hub / github.com/bytebase/dbhub / resolveTomlConfigPath

Function resolveTomlConfigPath

src/config/toml-loader.ts:59–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 * Priority: --config flag > ./dbhub.toml
58 */
59export function resolveTomlConfigPath(): string | null {
60 const args = parseCommandLineArgs();
61
62 // 1. Check for --config flag (highest priority)
63 if (args.config) {
64 const configPath = expandHomeDir(args.config);
65 if (!fs.existsSync(configPath)) {
66 throw new Error(
67 `Configuration file specified by --config flag not found: ${configPath}`
68 );
69 }
70 return configPath;
71 }
72
73 // 2. Check for dbhub.toml in current directory
74 const defaultConfigPath = path.join(process.cwd(), "dbhub.toml");
75 if (fs.existsSync(defaultConfigPath)) {
76 return defaultConfigPath;
77 }
78
79 return null;
80}
81
82/**
83 * Validate the structure of the parsed TOML configuration

Callers 2

startConfigWatcherFunction · 0.85
loadTomlConfigFunction · 0.85

Calls 2

parseCommandLineArgsFunction · 0.85
expandHomeDirFunction · 0.85

Tested by

no test coverage detected