Browse Source

chore: change remaining usages of `process.mainModule` (#38705)

David Sanders 1 year ago
parent
commit
f5869b6fb9

+ 1 - 1
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);

+ 1 - 1
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');
 }
 

+ 1 - 1
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');
 }
 

+ 1 - 1
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);

+ 1 - 1
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);

+ 1 - 1
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);