Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: do not initiate hooks if there are no hookfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed May 22, 2019
1 parent bad575f commit 0da05fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/addHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ module.exports = function addHooks(runner, transactions, callback) {
runner.hooks.transactions[transaction.name] = transaction;
});

// No hooks
if (!runner.configuration.hookfiles || !runner.configuration.hookfiles.length) {
return callback();
}

// Loading hookfiles from fs
let hookfiles;
try {
Expand Down
14 changes: 14 additions & 0 deletions test/unit/addHooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ describe('addHooks()', () => {

it('sets transactionRunner.hooks.configuation', (done) => {
const transactionRunner = createTransactionRunner();
transactionRunner.configuration.hookfiles = [
'./hooks.js',
];

addHooks(transactionRunner, [], (err) => {
assert.deepEqual(
Expand All @@ -83,4 +86,15 @@ describe('addHooks()', () => {
done(err);
});
});

it('skips hooks loading when there are no hookfiles', (done) => {
const transactionRunner = createTransactionRunner();
transactionRunner.configuration.hookfiles = [];
transactionRunner.configuration.language = 'python';

addHooks(transactionRunner, [], (err) => {
assert.isUndefined(transactionRunner.hooks.configuration);
done(err);
});
});
});

0 comments on commit 0da05fb

Please sign in to comment.