MCPcopy
hub / github.com/rollup/rollup / getConfigPath

Function getConfigPath

cli/run/getConfigPath.ts:9–29  ·  view source on GitHub ↗
(commandConfig: string | true)

Source from the content-addressed store, hash-verified

7const DEFAULT_CONFIG_BASE = 'rollup.config';
8
9export async function getConfigPath(commandConfig: string | true): Promise<string> {
10 if (commandConfig === true) {
11 return path.resolve(await findConfigFileNameInCwd());
12 }
13 if (commandConfig.slice(0, 5) === 'node:') {
14 const packageName = commandConfig.slice(5);
15 try {
16 return require.resolve(`rollup-config-${packageName}`, { paths: [cwd()] });
17 } catch {
18 try {
19 return require.resolve(packageName, { paths: [cwd()] });
20 } catch (error: any) {
21 if (error.code === 'MODULE_NOT_FOUND') {
22 handleError(logMissingExternalConfig(commandConfig));
23 }
24 throw error;
25 }
26 }
27 }
28 return path.resolve(commandConfig);
29}
30
31async function findConfigFileNameInCwd(): Promise<string> {
32 const filesInWorkingDirectory = new Set(await readdir(cwd()));

Callers 2

getConfigsFunction · 0.90
watchFunction · 0.90

Calls 3

handleErrorFunction · 0.90
logMissingExternalConfigFunction · 0.90
findConfigFileNameInCwdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…