Skip to content

Commit e31265f

Browse files
committed
feat: install latest mongodb binaries on package install
It helps to skip timeout setup `jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;` when first test run hits MongoDB binary downloading to the cache. Related #62
1 parent 52f2774 commit e31265f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"repository": "https://github.com/nodkz/mongodb-memory-server",
77
"author": "Nodkz ([email protected])",
88
"files": [
9-
"lib"
9+
"lib",
10+
"postinstall.js"
1011
],
1112
"keywords": [
1213
"mongodb",
@@ -71,7 +72,8 @@
7172
"lint": "eslint --ext .js ./src",
7273
"flow": "./node_modules/.bin/flow",
7374
"test": "npm run coverage && npm run lint && npm run flow",
74-
"semantic-release": "semantic-release"
75+
"semantic-release": "semantic-release",
76+
"postinstall": "node ./postinstall.js"
7577
},
7678
"jest": {
7779
"roots": [

postinstall.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
This script is used as postinstall hook.
3+
4+
When you install mongodb-memory-server package
5+
npm or yarn downloads the latest version of mongodb binaries.
6+
7+
It helps to skip timeout setup `jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;`
8+
when first test run hits MongoDB binary downloading to the cache.
9+
*/
10+
11+
const MongoBinary = require('./lib/util/MongoBinary').default;
12+
13+
console.log('mongodb-memory-server: checking MongoDB binaries cache...');
14+
MongoBinary.getPath({
15+
version: 'latest',
16+
}).then(binPath => {
17+
console.log(`mongodb-memory-server: binary path is ${binPath}`);
18+
});

0 commit comments

Comments
 (0)