fix(setup): print an info message (#3698)

This commit is contained in:
Zoltan Kochan
2021-08-22 19:21:45 +03:00
committed by GitHub
parent 55bb14a674
commit 71cc218328
2 changed files with 18 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-setup": major
---
Print info message about the requirment to open a new terminal.

View File

@@ -61,17 +61,27 @@ export async function handler (
if (execPath.match(/\.[cm]?js$/) == null) {
moveCli(execPath, opts.pnpmHomeDir)
}
const updateOutput = await updateShell(currentShell, opts.pnpmHomeDir)
if (updateOutput === false) {
return 'Could not infer shell type.'
}
return `${updateOutput}
Setup complete. Open a new terminal to start using pnpm.`
}
async function updateShell (currentShell: string | null, pnpmHomeDir: string): Promise<string | false> {
switch (currentShell) {
case 'bash': {
const configFile = path.join(os.homedir(), '.bashrc')
return setupShell(configFile, opts.pnpmHomeDir)
return setupShell(configFile, pnpmHomeDir)
}
case 'zsh': {
const configFile = path.join(os.homedir(), '.zshrc')
return setupShell(configFile, opts.pnpmHomeDir)
return setupShell(configFile, pnpmHomeDir)
}
case 'fish': {
return setupFishShell(opts.pnpmHomeDir)
return setupFishShell(pnpmHomeDir)
}
}
return 'Could not infer shell type.'