You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the bottom of bin.ts has some core functionality we want to expose. one primary usecase is to get the launch+runlighthouse+getresults flow is available to other modules (see addyosmani/webpack-lighthouse-plugin#5)
other usecase is better tests of the CLI.. these methods arent testable as they sit in bin.ts which requires CLI interaction
Here's the current summary of the two files:
-core/index
throw if missing URL
set logging defaults
generate config from provided json
set up CRI connection
call Runner.run()
-cli/bin.ts
call getFlags() and process early stdout exits
read configPath from disk
set logging defaults
set outputpath defaults
show errors, for a number of cases:
console.error readable error
process.exit w/ code
runLighthouse
call launcher.launch()
call -core/index
call saveResults
handle --interactive mode
kill launcher
call handleError
saveResults
call saveArtifacts (which saves to disk)
call saveAssets (which saves to disk)
prepare filenames
call Printer.write()
call opn()
Ideally much of the items in bin.ts move into index.js. However when you dig into it, this refactor gets a little hairy. For example: handleError both logs a friendly error message and process exits. Half of this is appropriate when LH is a node dependency. Another example: Some webpack-lighthouse-plugin wants to use save-assets and have the report saved to disk but shouldn't get reminded to run LH with the --view flag.
None of this is particularly hard, but it would require time and testing to do it right.
I'm proposing an intermediate fix that will unblock webpack-lighthouse-plugin among others. This fix: move much of bin.ts into its own file that can be safely require()'d without any yargs interference. PR incoming..
The text was updated successfully, but these errors were encountered:
the bottom of bin.ts has some core functionality we want to expose. one primary usecase is to get the launch+runlighthouse+getresults flow is available to other modules (see addyosmani/webpack-lighthouse-plugin#5)
other usecase is better tests of the CLI.. these methods arent testable as they sit in bin.ts which requires CLI interaction
Here's the current summary of the two files:
-core/index
-cli/bin.ts
Ideally much of the items in
bin.ts
move intoindex.js
. However when you dig into it, this refactor gets a little hairy. For example:handleError
both logs a friendly error message and process exits. Half of this is appropriate when LH is a node dependency. Another example: Some webpack-lighthouse-plugin wants to usesave-assets
and have the report saved to disk but shouldn't get reminded to run LH with the--view
flag.None of this is particularly hard, but it would require time and testing to do it right.
I'm proposing an intermediate fix that will unblock webpack-lighthouse-plugin among others. This fix: move much of bin.ts into its own file that can be safely require()'d without any yargs interference. PR incoming..
The text was updated successfully, but these errors were encountered: