-
Notifications
You must be signed in to change notification settings - Fork 930
feat(cli): implement print-config cli flag #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import stdin from 'get-stdin'; | |
import resolveFrom from 'resolve-from'; | ||
import resolveGlobal from 'resolve-global'; | ||
import yargs from 'yargs'; | ||
import util from 'util'; | ||
|
||
import {CliFlags, Seed} from './types'; | ||
import { | ||
|
@@ -33,6 +34,11 @@ const cli = yargs | |
description: 'path to the config file', | ||
type: 'string', | ||
}, | ||
'print-config': { | ||
type: 'boolean', | ||
default: false, | ||
description: 'print resolved config', | ||
}, | ||
cwd: { | ||
alias: 'd', | ||
default: process.cwd(), | ||
|
@@ -123,6 +129,16 @@ main({edit: false, ...cli.argv}).catch((err) => { | |
async function main(options: CliFlags) { | ||
const raw = options._; | ||
const flags = normalizeFlags(options); | ||
|
||
if (flags['print-config']) { | ||
const loaded = await load(getSeed(flags), { | ||
cwd: flags.cwd, | ||
file: flags.config, | ||
}); | ||
Comment on lines
+134
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure if this is best way to get resolved config, should we include here configuration that comes from cli arguments? i think load should not return extends There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that would be nice to always reflect the actual used configuration.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ok, than its correct |
||
console.log(util.inspect(loaded, false, null, options.color)); | ||
return; | ||
} | ||
|
||
const fromStdin = checkFromStdin(raw, flags); | ||
|
||
const input = await (fromStdin | ||
|
@@ -149,8 +165,10 @@ async function main(options: CliFlags) { | |
throw err; | ||
} | ||
|
||
const loadOpts = {cwd: flags.cwd, file: flags.config}; | ||
const loaded = await load(getSeed(flags), loadOpts); | ||
const loaded = await load(getSeed(flags), { | ||
cwd: flags.cwd, | ||
file: flags.config, | ||
}); | ||
const parserOpts = selectParserOpts(loaded.parserPreset); | ||
const opts: LintOptions & {parserOpts: ParserOptions} = { | ||
parserOpts: {}, | ||
|
Uh oh!
There was an error while loading. Please reload this page.