diff --git a/script/lint.js b/script/lint.js index f5cc4c9b6a..7b6405a4bd 100755 --- a/script/lint.js +++ b/script/lint.js @@ -353,7 +353,7 @@ async function main () { } } -if (process.mainModule === module) { +if (require.main === module) { main().catch((error) => { console.error(error); process.exit(1); diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index 04c8459a08..85aebb15f6 100644 --- a/script/nan-spec-runner.js +++ b/script/nan-spec-runner.js @@ -9,7 +9,7 @@ const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'; const utils = require('./lib/utils'); const { YARN_VERSION } = require('./yarn'); -if (!process.mainModule) { +if (!require.main) { throw new Error('Must call the nan spec runner directly'); } diff --git a/script/node-spec-runner.js b/script/node-spec-runner.js index 78d881ddd1..f365886b0a 100644 --- a/script/node-spec-runner.js +++ b/script/node-spec-runner.js @@ -15,7 +15,7 @@ const TAP_FILE_NAME = 'test.tap'; const utils = require('./lib/utils'); -if (!process.mainModule) { +if (!require.main) { throw new Error('Must call the node spec runner directly'); } diff --git a/script/push-patch.js b/script/push-patch.js index b2cdbd2eff..8f7bc86326 100644 --- a/script/push-patch.js +++ b/script/push-patch.js @@ -31,7 +31,7 @@ async function main () { } } -if (process.mainModule === module) { +if (require.main === module) { main().catch((err) => { console.error(err); process.exit(1); diff --git a/script/release/notes/index.js b/script/release/notes/index.js index 5923138502..567135faf8 100755 --- a/script/release/notes/index.js +++ b/script/release/notes/index.js @@ -200,7 +200,7 @@ For example, these invocations are equivalent: } } -if (process.mainModule === module) { +if (require.main === module) { main().catch((err) => { console.error('Error Occurred:', err); process.exit(1); diff --git a/script/release/version-bumper.js b/script/release/version-bumper.js index 1045345788..78e5551b32 100644 --- a/script/release/version-bumper.js +++ b/script/release/version-bumper.js @@ -109,7 +109,7 @@ function isMajorNightly (version, currentVersion) { return false; } -if (process.mainModule === module) { +if (require.main === module) { main().catch((error) => { console.error(error); process.exit(1);