mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-05 07:46:10 -04:00
fix(setup): update the current shell, not the preferred one (#4701)
ref #4658
This commit is contained in:
6
.changeset/calm-ravens-rest.md
Normal file
6
.changeset/calm-ravens-rest.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-setup": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm setup` should update the config of the current shell, not the preferred shell.
|
||||
@@ -50,7 +50,7 @@ export async function handler (
|
||||
pnpmHomeDir: string
|
||||
}
|
||||
) {
|
||||
const currentShell = typeof process.env.SHELL === 'string' ? path.basename(process.env.SHELL) : null
|
||||
const currentShell = detectCurrentShell()
|
||||
const execPath = getExecPath()
|
||||
if (execPath.match(/\.[cm]?js$/) == null) {
|
||||
copyCli(execPath, opts.pnpmHomeDir)
|
||||
@@ -61,6 +61,13 @@ export async function handler (
|
||||
Setup complete. Open a new terminal to start using pnpm.`
|
||||
}
|
||||
|
||||
function detectCurrentShell () {
|
||||
if (process.env.ZSH_VERSION) return 'zsh'
|
||||
if (process.env.BASH_VERSION) return 'bash'
|
||||
if (process.env.FISH_VERSION) return 'fish'
|
||||
return typeof process.env.SHELL === 'string' ? path.basename(process.env.SHELL) : null
|
||||
}
|
||||
|
||||
async function updateShell (currentShell: string | null, pnpmHomeDir: string): Promise<string> {
|
||||
switch (currentShell) {
|
||||
case 'bash': {
|
||||
|
||||
Reference in New Issue
Block a user