Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit a56e39b

Browse files
committed
fix: load plugins only once
1 parent 05d10da commit a56e39b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/gemini.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ module.exports = class Gemini extends PassthroughEmitter {
103103
}
104104

105105
_exec(fn) {
106-
const plugins = pluginsLoader.load(this, this.config.system.plugins, PREFIX);
107-
return bluebirdQ(Promise.all(plugins).then(() => fn()));
106+
return bluebirdQ(this._loadPlugins().then(() => fn()));
107+
}
108+
109+
_loadPlugins() {
110+
this._loadPlugins = () => Promise.resolve(); // load plugins only once
111+
return Promise.all(pluginsLoader.load(this, this.config.system.plugins, PREFIX));
108112
}
109113

110114
_readTests(paths, options) {

test/unit/gemini.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ describe('gemini', () => {
183183
return assert.isRejected(result, err)
184184
.then(() => assert.notCalled(Runner.prototype.run));
185185
});
186+
187+
it('should load plugins only once', () => {
188+
const gemini = initGemini();
189+
190+
return gemini.readTests()
191+
.then((collection) => gemini.test(collection))
192+
.then(() => assert.calledOnce(pluginsLoader.load));
193+
});
186194
});
187195

188196
describe('readTests', () => {

0 commit comments

Comments
 (0)