[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
3 changes: 3 additions & 0 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ 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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a description specifying that other flags will override this one? (e.g. --throttling-method=provided on the command line will override "throttling-method": "devtools" in the settings file)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, bikeshed time: should we call it something like cli-flags-path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, copy over to readme :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a description specifying that other flags will override this one?

Yes, test added too! 👍

cli-flags-path

WFM!

also, copy over to readme

This feels close to an autopopulate script too if only we made changes more frequently 🤔

Copy link
Member
@brendankenny brendankenny Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels close to an autopopulate script too if only we made changes more frequently 🤔

definitely, and it's a little silly we have it at all, but I know I've at least found it useful in the past, so.... 🤷‍♀


// List of options
.group(['verbose', 'quiet'], 'Logging:')
.describe({
Expand Down
17 changes: 17 additions & 0 deletions lighthouse-cli/test/cli/cli-flags-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ 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"`,
].join(' '));

expect(flags).toMatchObject({
onlyCategories: ['performance', 'seo'],
chromeFlags: '--window-size 800,600',
throttlingMethod: 'devtools',
throttling: {
requestLatencyMs: 700,
cpuSlowdownMultiplier: 6,
},
});
});

it('array values support csv when appropriate', () => {
const flags = getFlags([
'http://www.example.com',
Expand Down
9 changes: 9 additions & 0 deletions lighthouse-cli/test/fixtures/cli-settings-path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"onlyCategories": ["performance", "seo"],
"chromeFlags": "--window-size 800,600",
"throttling-method": "devtools",
"throttling": {
"requestLatencyMs": 700,
"cpuSlowdownMultiplier": 6
}
}