From 878939007eda254e93a5afaa4244fc45c662b8e6 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Wed, 10 Apr 2024 01:09:57 +0900 Subject: [PATCH 1/2] fix: get package manager --- src/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 95e8aa1..bc9e73b 100755 --- a/src/index.js +++ b/src/index.js @@ -16,11 +16,7 @@ const brandColor = /** @type {const} */ ([174, 128, 255]); // // Don't love the flag, need to find a better name. const skipHint = process.argv.slice(2).includes('--skip-hints'); - const packageManager = /yarn/.test(process.env.npm_execpath) - ? 'yarn' - : process.env.PNPM_PACKAGE_NAME - ? 'pnpm' - : 'npm'; + const packageManager = getPkgManager(); prompts.intro( kl.trueColor(...brandColor)( @@ -252,3 +248,14 @@ function installPackages(pkgs, opts) { }, ); } + +/** + * + * @returns {'yarn' | 'pnpm' | 'npm'} + */ +function getPkgManager() { + const userAgent = process.env.npm_config_user_agent || '' + if (userAgent.startsWith('yarn')) return 'yarn' + if (userAgent.startsWith('pnpm')) return 'pnpm' + return 'npm' +} From a13beaf82fd8a6e9eb9cbf53c9f6ec4cfc0df993 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:23:13 -0500 Subject: [PATCH 2/2] Update src/index.js --- src/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.js b/src/index.js index bc9e73b..d0d24ce 100755 --- a/src/index.js +++ b/src/index.js @@ -250,7 +250,6 @@ function installPackages(pkgs, opts) { } /** - * * @returns {'yarn' | 'pnpm' | 'npm'} */ function getPkgManager() {