Skip to content

Commit 0f1dc61

Browse files
committed
fix: do not block packages instalation when occured problem with mongodb binary download
Related #131
1 parent 739c99a commit 0f1dc61

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

postinstall.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,35 @@ when first test run hits MongoDB binary downloading to the cache.
99
*/
1010

1111
function isModuleExists(name) {
12-
try { return !!require.resolve(name); }
13-
catch(e) { return false }
12+
try {
13+
return !!require.resolve(name);
14+
} catch (e) {
15+
return false;
16+
}
1417
}
1518

16-
const skipDownload = (typeof process.env.MONGOMS_DISABLE_POSTINSTALL === 'string') &&
17-
(['1', 'on', 'yes', 'true'].indexOf(process.env.MONGOMS_DISABLE_POSTINSTALL.toLowerCase()) !== -1)
19+
const skipDownload =
20+
typeof process.env.MONGOMS_DISABLE_POSTINSTALL === 'string' &&
21+
['1', 'on', 'yes', 'true'].indexOf(process.env.MONGOMS_DISABLE_POSTINSTALL.toLowerCase()) !== -1;
1822

1923
if (skipDownload) {
20-
console.log("Download is skipped by MONGOMS_DISABLE_POSTINSTALL variable");
24+
console.log('Download is skipped by MONGOMS_DISABLE_POSTINSTALL variable');
2125
process.exit(0);
2226
}
2327

2428
if (isModuleExists('./lib/util/MongoBinary')) {
2529
const MongoBinary = require('./lib/util/MongoBinary').default;
2630

2731
console.log('mongodb-memory-server: checking MongoDB binaries cache...');
28-
MongoBinary.getPath({}).then(binPath => {
29-
console.log(`mongodb-memory-server: binary path is ${binPath}`);
30-
})
31-
.catch((err) => {
32-
console.log(`failed to download/install MongoDB binaries. The error:
33-
${err}`)
34-
process.exit(1)
35-
});
32+
MongoBinary.getPath({})
33+
.then(binPath => {
34+
console.log(`mongodb-memory-server: binary path is ${binPath}`);
35+
})
36+
.catch(err => {
37+
console.log(`failed to download/install MongoDB binaries. The error:
38+
${err}`);
39+
process.exit(0);
40+
});
3641
} else {
3742
console.log("Can't resolve MongoBinary module");
3843
}

0 commit comments

Comments
 (0)