MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / getConfig

Function getConfig

packages/core/cli/src/utils/get-config.ts:13–47  ·  view source on GitHub ↗
(opts: {
  cwd: string;
  configPath?: string;
})

Source from the content-addressed store, hash-verified

11];
12
13export const getConfig = async (opts: {
14 cwd: string;
15 configPath?: string;
16}): Promise<ExecutorCliConfig | null> => {
17 const { cwd, configPath } = opts;
18
19 let resolvedPath: string | undefined;
20
21 if (configPath) {
22 resolvedPath = path.resolve(cwd, configPath);
23 if (!existsSync(resolvedPath)) {
24 console.error(`Config file not found: ${resolvedPath}`);
25 return null;
26 }
27 } else {
28 for (const p of defaultPaths) {
29 const candidate = path.resolve(cwd, p);
30 if (existsSync(candidate)) {
31 resolvedPath = candidate;
32 break;
33 }
34 }
35 }
36
37 if (!resolvedPath) return null;
38
39 const jiti = createJiti(cwd, {
40 interopDefault: true,
41 moduleCache: false,
42 });
43
44 const mod = await jiti.import(resolvedPath);
45 const config = (mod as { default?: ExecutorCliConfig }).default ?? mod;
46 return config as ExecutorCliConfig;
47};

Callers 1

generateRouteTreeFunction · 0.50

Calls 2

resolveMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected