From 6a5bd8dc289a00ca2d2f77e4af328f794d8b1a8d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 09:42:50 -0400 Subject: [PATCH] chore: `process.mainModule` -> `require.main` (#38477) chore: process.mainModule -> require.main Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- script/yarn.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/script/yarn.js b/script/yarn.js index 08ff088327b6f..353a183244257 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;