From b233d0805a5d6e8664df12209a8ce9c5cc75ea3c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 29 May 2023 10:44:09 +0200 Subject: [PATCH] chore: `process.mainModule` -> `require.main` (#38452) chore: process.mainModule -> require.main --- script/yarn.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/script/yarn.js b/script/yarn.js index 08ff088327b..353a1832442 100644 --- a/script/yarn.js +++ b/script/yarn.js @@ -3,13 +3,9 @@ const fs = require('fs'); const path = require('path'); const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1]; +const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'; -exports.YARN_VERSION = YARN_VERSION; - -// If we are running "node script/yarn" run as the yarn CLI -if (process.mainModule === module) { - const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'; - +if (require.main === module) { const child = cp.spawn(NPX_CMD, [`yarn@${YARN_VERSION}`, ...process.argv.slice(2)], { stdio: 'inherit', env: { @@ -20,3 +16,5 @@ if (process.mainModule === module) { child.on('exit', code => process.exit(code)); } + +exports.YARN_VERSION = YARN_VERSION;