Skip to content

Commit

Permalink
use try catch for installing chai-bn for user (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio authored Oct 16, 2019
1 parent ba23eb2 commit 135c3e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ require('chai').use(chaiBN);
// has in their own tests. This can happen if the version ranges required don't
// intersect, or if the package manager doesn't dedupe the modules for any
// other reason. We do our best to install chai-bn for the user.
function useChaiBN (chai) { if (chai) chai.use(chaiBN); }
useChaiBN(require.main.require('chai'));
useChaiBN(module.parent.require('chai'));
for (const mod of [require.main, module.parent]) {
try {
mod.require('chai').use(chaiBN);
} catch (e) {
// Ignore errors
}
}

module.exports = {
web3,
Expand Down

0 comments on commit 135c3e8

Please sign in to comment.