Skip to content

Commit 16bba79

Browse files
committed
fix: more accurate package manager inferring
1 parent 1992b15 commit 16bba79

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,10 @@ async function init() {
337337
// Supported package managers: pnpm > yarn > npm
338338
// Note: until <https://github.com/pnpm/pnpm/issues/3505> is resolved,
339339
// it is not possible to tell if the command is called by `pnpm init`.
340-
const packageManager = /pnpm/.test(process.env.npm_execpath)
340+
const packageManagerBinary = path.basename(process.env.npm_execpath)
341+
const packageManager = /pnpm/.test(packageManagerBinary)
341342
? 'pnpm'
342-
: /yarn/.test(process.env.npm_execpath)
343+
: /yarn/.test(packageManagerBinary)
343344
? 'yarn'
344345
: 'npm'
345346

0 commit comments

Comments
 (0)