UNPKG

mongodb-memory-server

Version:

In-memory MongoDB Server. Designed with testing in mind, the server will allow you to connect your favourite ODM or client library to the MongoDB Server and run integration tests isolated from each other.

35 lines (27 loc) 1.09 kB
/* This script is used as postinstall hook. When you install mongodb-memory-server package npm or yarn downloads the latest version of mongodb binaries. It helps to skip timeout setup `jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;` when first test run hits MongoDB binary downloading to the cache. */ function isModuleExists(name) { try { return !!require.resolve(name); } catch(e) { return false } } const skipDownload = typeof process.env.MONGOMS_DISABLE_POSTINSTALL === 'string' ? ['1', 'on', 'yes', 'true'].indexOf(process.env.MONGOMS_DISABLE_POSTINSTALL.toLowerCase()) !== -1 : false; if (skipDownload) { console.log("Download is skipped by MONGOMS_DISABLE_POSTINSTALL variable"); process.exit(0); } if (isModuleExists('./lib/util/MongoBinary')) { const MongoBinary = require('./lib/util/MongoBinary').default; console.log('mongodb-memory-server: checking MongoDB binaries cache...'); MongoBinary.getPath({}).then(binPath => { console.log(`mongodb-memory-server: binary path is ${binPath}`); }); } else { console.log("Can't resolve MongoBinary module"); }