Skip to content

Commit

Permalink
fix(postinstall): skip postinstall if "SYSTEM_BINARY" is set
Browse files Browse the repository at this point in the history
- skip "mongodb-memory-server"'s postinstall if "SYSTEM_BINARY" is set
- disable eslint-rule "@typescript-eslint/no-var-requires" for all postinstalls

closes #370
  • Loading branch information
hasezoey committed Sep 12, 2020
1 parent 82606d8 commit 34b1f1f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global-3.4/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global-3.6/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global-4.0/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global-4.2/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global-4.4/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
2 changes: 2 additions & 0 deletions packages/mongodb-memory-server-global/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

function isModuleExists(name) {
try {
return !!require.resolve(name);
Expand Down
15 changes: 11 additions & 4 deletions packages/mongodb-memory-server/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/no-var-requires: 0 */

/*
This script is used as postinstall hook.
Expand All @@ -20,19 +22,24 @@ if (!isModuleExists('../mongodb-memory-server-core/lib/util/resolve-config')) {
console.log('Could not resolve postinstall configuration');
return;
}
// eslint-disable-next-line @typescript-eslint/no-var-requires

const rc = require('../mongodb-memory-server-core/lib/util/resolve-config');
rc.reInitializePackageJson(process.env.INIT_CWD);

const envDisablePostinstall = rc.default('DISABLE_POSTINSTALL');
const skipDownload =
typeof envDisablePostinstall === 'string' && rc.envToBool(envDisablePostinstall);

if (skipDownload) {
if (typeof envDisablePostinstall === 'string' && rc.envToBool(envDisablePostinstall)) {
console.log('Download is skipped by MONGOMS_DISABLE_POSTINSTALL variable');
process.exit(0);
}

const envSystemBinary = rc.default('SYSTEM_BINARY');

if (typeof envSystemBinary === 'string') {
console.log('Download is skipped by MONGOMS_SYSTEM_BINARY variable');
process.exit(0);
}

const mongoBinaryModule = '../mongodb-memory-server-core/lib/util/MongoBinary';
if (isModuleExists(mongoBinaryModule)) {
const MongoBinary = require(mongoBinaryModule).default;
Expand Down

0 comments on commit 34b1f1f

Please sign in to comment.