Skip to content

Commit

Permalink
core: look up custom gatherer relative to the config file path (#4751)
Browse files Browse the repository at this point in the history
  • Loading branch information
echopi authored and patrickhulce committed Mar 15, 2018
1 parent 22bd981 commit a58dc1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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 @@ -673,6 +673,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

0 comments on commit a58dc1f

Please sign in to comment.