/
getConfig.ts
34 lines (30 loc) · 1 KB
/
getConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { packageManager } from '@pnpm/cli-meta'
import { getConfig as _getConfig, type CliOptions } from '@pnpm/config'
import { formatWarn } from '@pnpm/default-reporter'
export async function getConfig (
cliOptions: CliOptions,
opts: {
excludeReporter: boolean
globalDirShouldAllowWrite?: boolean
rcOptionsTypes: Record<string, unknown>
workspaceDir: string | undefined
checkUnknownSetting?: boolean
}
) {
const { config, warnings } = await _getConfig({
cliOptions,
globalDirShouldAllowWrite: opts.globalDirShouldAllowWrite,
packageManager,
rcOptionsTypes: opts.rcOptionsTypes,
workspaceDir: opts.workspaceDir,
checkUnknownSetting: opts.checkUnknownSetting,
})
config.cliOptions = cliOptions
if (opts.excludeReporter) {
delete config.reporter // This is a silly workaround because @pnpm/core expects a function as opts.reporter
}
if (warnings.length > 0) {
console.log(warnings.map((warning) => formatWarn(warning)).join('\n'))
}
return config
}