fix(lighthouse): hide logs timestamp when running in tty #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See before:
https://app.netlify.com/sites/plugin-lighthouse/deploys/5f0c23c7c9f52900075bf9ca
And after:
https://app.netlify.com/sites/plugin-lighthouse/deploys/5f0c4a4177fc940007d8a269
Lighthouse uses
debug
as a dependency which appends a timestamp when in tty:https://github.com/visionmedia/debug/blob/80ef62a3af4df95250d77d64edfc3d0e1667e7e8/src/node.js#L174
https://github.com/visionmedia/debug/blob/80ef62a3af4df95250d77d64edfc3d0e1667e7e8/src/node.js#L151
With older versions (like the one lighthouse uses) the only way to change it is via
colors
option (with newer versions there is a simplerhideDate
option).We previously used
require('debug').inspectOpts.colors = true
to set the option, but that only works for the resolved version ofdebug
and not all versions in the dependency tree.A better fix is to use an environment variable to set the option for all
debug
versions. See https://github.com/visionmedia/debug/blob/80ef62a3af4df95250d77d64edfc3d0e1667e7e8/src/node.js#L120