From bb41ef6fd85a803a4a22e8382f67ea9e3e235b7d Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 28 Oct 2022 09:22:49 -0400 Subject: [PATCH 1/2] Add a proper check for yarn Before, `isYarn` would be false if you ran yarn using `npx`. --- lib/run-task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/run-task.js b/lib/run-task.js index b875dcd..168c86c 100644 --- a/lib/run-task.js +++ b/lib/run-task.js @@ -157,7 +157,7 @@ module.exports = function runTask(task, options) { const npmPath = options.npmPath || process.env.npm_execpath //eslint-disable-line no-process-env const npmPathIsJs = typeof npmPath === "string" && /\.m?js/.test(path.extname(npmPath)) const execPath = (npmPathIsJs ? process.execPath : npmPath || "npm") - const isYarn = path.basename(npmPath || "npm").startsWith("yarn") + const isYarn = process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith("yarn") //eslint-disable-line no-process-env const spawnArgs = ["run"] if (npmPathIsJs) { From 022416740f0d9cf8eae2f2e4ca4de8d09a6b67d8 Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 28 Oct 2022 09:24:04 -0400 Subject: [PATCH 2/2] Use NPM_CLI_JS over npm_execpath npm_execpath points to npx if you are running this inside of npx --- lib/run-task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/run-task.js b/lib/run-task.js index 168c86c..8684b52 100644 --- a/lib/run-task.js +++ b/lib/run-task.js @@ -154,7 +154,7 @@ module.exports = function runTask(task, options) { } // Execute. - const npmPath = options.npmPath || process.env.npm_execpath //eslint-disable-line no-process-env + const npmPath = options.npmPath || process.env.NPM_CLI_JS || process.env.npm_execpath //eslint-disable-line no-process-env const npmPathIsJs = typeof npmPath === "string" && /\.m?js/.test(path.extname(npmPath)) const execPath = (npmPathIsJs ? process.execPath : npmPath || "npm") const isYarn = process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith("yarn") //eslint-disable-line no-process-env