MCPcopy
hub / github.com/prisma/prisma / loadConfig

Function loadConfig

packages/cli/src/utils/loadConfig.ts:15–52  ·  view source on GitHub ↗
(
  configFilePath?: string,
)

Source from the content-addressed store, hash-verified

13 * Will try to load the prisma config file from the given path, default path or create a default config.
14 */
15export async function loadConfig(
16 configFilePath?: string,
17): Promise<{ config: PrismaConfigInternal; diagnostics: ConfigDiagnostic[] } | HelpError> {
18 const { config, error, resolvedPath, diagnostics } = await loadConfigFromFile({ configFile: configFilePath })
19
20 if (error) {
21 debug('Error loading config file: %o', error)
22 switch (error._tag) {
23 case 'ConfigFileNotFound':
24 return new HelpError(`Config file not found at "${resolvedPath}"`)
25
26 case 'ConfigLoadError':
27 if (error.error instanceof PrismaConfigEnvError) {
28 diagnostics.push({
29 _tag: 'warn',
30 value: (formatters) => () => {
31 formatters.log(formatters.dim(`${error.error.message}`))
32 },
33 })
34 }
35
36 return new HelpError(
37 `Failed to load config file "${resolvedPath}" as a TypeScript/JavaScript module. Error: ${error.error}`,
38 )
39
40 case 'ConfigFileSyntaxError':
41 return new HelpError(`Failed to parse syntax of config file at "${resolvedPath}"`)
42
43 case 'UnknownError':
44 return new HelpError(`Unknown error during config file loading: ${error.error}`)
45
46 default:
47 assertNever(error, `Unhandled error '${JSON.stringify(error)}' in 'loadConfigFromFile'.`)
48 }
49 }
50
51 return { config, diagnostics }
52}

Callers 3

mainFunction · 0.90
loadConfig.test.tsFile · 0.90
configContextContributorFunction · 0.90

Calls 5

loadConfigFromFileFunction · 0.90
assertNeverFunction · 0.90
debugFunction · 0.85
logMethod · 0.80
pushMethod · 0.45

Tested by 1

configContextContributorFunction · 0.72