clean up of extensible audit loading and error handling #679
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.
This came from @ebidel making his own custom audits. Any errors in a custom audit (e.g. syntax error or transitive dependencies not being found) were being absorbed and reemitted as "Unable to locate audit", which is not true and confusing.
In fixing this, however, it also became clear that our audit resolution was being done in a really fragile way, so this PR changes a few things:
require()
in place. No one is going to specify their paths relative tolighthouse-core/config/config.js
, but this handles the audit-in-an-npm module case by walking up and down the path looking for audits innode_modules/
directories.process.cwd()
. Resolving relative to the working directory is mostly to handle the case of using Lighthouse as a module since then you're passing in a config object, not a file, so there is no config file path.config.js
, and we won't always be able to locate it ourselves by this point. I've put in an assertion in theConfig
constructor to make sure the path is absolute by that point and made sure the CLI handles that properly.