Skip to content

Commit 97f2666

Browse files
feat(cli): add a --printMergedOptions flag
1 parent 87d2af9 commit 97f2666

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

core/cli/bin/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ async function main() {
2323
} else if (argv.printConfig) {
2424
const { printConfig } = require('../lib')
2525
await printConfig(rootLogger)
26+
} else if (argv.printMergedOptions) {
27+
const { printMergedOptions } = require('../lib')
28+
await printMergedOptions(rootLogger)
2629
} else if (argv.help || argv._.length === 0) {
2730
const showHelp = require('../lib/help').default
2831
await showHelp(rootLogger, argv._)

core/cli/src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { loadConfig } from './config'
22
import type { Logger } from 'winston'
33
import util from 'util'
44
import { formatPluginTree } from './messages'
5+
import { loadHookInstallations } from './install'
56

67
export { runTasks } from './tasks'
78
export { shouldDisableNativeFetch } from './fetch'
@@ -20,3 +21,23 @@ export async function printConfig(logger: Logger): Promise<void> {
2021

2122
logger.info(util.inspect(config, { depth: null, colors: true }))
2223
}
24+
25+
export async function printMergedOptions(logger: Logger): Promise<void> {
26+
const config = await loadConfig(logger, { validate: true, root: process.cwd() })
27+
const hookInstallations = (await loadHookInstallations(logger, config)).unwrap('invalid hooks')
28+
29+
const mergedOptions = {
30+
hooks: hookInstallations.map((h) => h.options),
31+
plugins: Object.fromEntries(
32+
Object.entries(config.pluginOptions).map(([pluginId, optionsForPlugin]) => [
33+
pluginId,
34+
optionsForPlugin.options
35+
])
36+
),
37+
tasks: Object.fromEntries(
38+
Object.entries(config.taskOptions).map(([taskId, optionsForTask]) => [taskId, optionsForTask.options])
39+
)
40+
}
41+
42+
logger.info(util.inspect(mergedOptions, { depth: null, colors: true }))
43+
}

0 commit comments

Comments
 (0)