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: look up custom gatherer relative to the config file path #4751

Merged
merged 2 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lighthouse-core/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Config {
// Store the directory of the config path, if one was provided.
this._configDir = configPath ? path.dirname(configPath) : undefined;

this._passes = Config.requireGatherers(configJSON.passes);
this._passes = Config.requireGatherers(configJSON.passes, this._configDir);
this._audits = Config.requireAudits(configJSON.audits, this._configDir);
this._artifacts = expandArtifacts(configJSON.artifacts);
this._categories = configJSON.categories;
Expand Down
10 changes: 10 additions & 0 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,16 @@ describe('Config', () => {
assert.equal(typeof gatherer.instance.beforePass, 'function');
});

it('loads a gatherer relative to a config path', () => {
const config = new Config({
passes: [{gatherers: ['../fixtures/valid-custom-gatherer']}],
}, __filename);
const gatherer = config.passes[0].gatherers[0];

assert.equal(gatherer.instance.name, 'CustomGatherer');
assert.equal(typeof gatherer.instance.beforePass, 'function');
});

it('returns gatherer when gatherer class, not package-name string, is provided', () => {
class TestGatherer extends Gatherer {}
const gatherer = loadGatherer(TestGatherer);
Expand Down