Skip to content

Commit

Permalink
Improve local vs global detection of pnpm and yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Apr 8, 2024
1 parent c1f143a commit b5c8676
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/actions/install-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,25 @@ module.exports = function hydrator (params, callback) {
}
else if (isPnpm) {
prodFlag = isRoot ? '' : '--prod'
let localPnpm = exists(join(cwd, 'node_modules', 'pnpm'))
let localPnpm
try {
// eslint-disable-next-line
require.resolve('pnpm')
localPnpm = true
}
catch { /* noop */ }
let cmd = localPnpm ? `npx pnpm i ${prodFlag}` : `pnpm i ${prodFlag}`
exec(cmd, options, callback)
}
else if (isYarn) {
let localYarn = exists(join(cwd, 'node_modules', 'yarn'))
let localYarn
try {
// eslint-disable-next-line
require.resolve('yarn')
localYarn = true
}
catch { /* noop */ }
localYarn = true
let cmd = localYarn ? `npx yarn ${prodFlag}` : `yarn ${prodFlag}`
exec(cmd, options, callback)
}
Expand Down

0 comments on commit b5c8676

Please sign in to comment.