[go: nahoru, domu]

Skip to content
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

core(cli): accept flags from path #9109

Merged
merged 3 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feedback
  • Loading branch information
patrickhulce committed Jun 3, 2019
commit c2541c6e4f1031b8da24d15db508a8629a9daebc
12 changes: 10 additions & 2 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ function getFlags(manualArgv) {
'lighthouse <url> --only-categories=performance,pwa',
'Only run specific categories.')

// Accept a file for all of these flags.
.config('cli-settings-path')
/**
* Also accept a file for all of these flags. Yargs will merge in and override the file-based
* flags with the command-line flags.
*
* i.e. when command-line `--throttling-method=provided` and file `throttlingMethod: "devtools"`,
* throttlingMethod will be `provided`.
*
* @see https://github.com/yargs/yargs/blob/a6e67f15a61558d0ba28bfe53385332f0ce5d431/docs/api.md#config
*/
.config('cli-flags-path')

// List of options
.group(['verbose', 'quiet'], 'Logging:')
Expand Down
4 changes: 3 additions & 1 deletion lighthouse-cli/test/cli/cli-flags-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ describe('CLI bin', function() {
it('settings are accepted from a file path', () => {
const flags = getFlags([
'http://www.example.com',
`--cli-settings-path="${__dirname}/../fixtures/cli-settings-path.json"`,
`--cli-flags-path="${__dirname}/../fixtures/cli-flags-path.json"`,
'--budgets-path=path/to/my/budget-from-command-line.json', // this should override the config value
].join(' '));

expect(flags).toMatchObject({
budgetsPath: 'path/to/my/budget-from-command-line.json',
onlyCategories: ['performance', 'seo'],
chromeFlags: '--window-size 800,600',
throttlingMethod: 'devtools',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"budgetPath": "path/to/my/budget-from-config.json",
"onlyCategories": ["performance", "seo"],
"chromeFlags": "--window-size 800,600",
"throttling-method": "devtools",
Expand Down