Skip to content

Commit

Permalink
fix: trailing whitespace after shell plugin causes extra doctor warni…
Browse files Browse the repository at this point in the history
…ngs (#323)

Signed-off-by: Chapman Pendery <[email protected]>
  • Loading branch information
cpendery authored Jan 6, 2025
1 parent 84dbfb8 commit aca796a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export const checkShellConfigPlugin = async () => {
if (profilePath != null && fs.existsSync(profilePath)) {
const profile = await fsAsync.readFile(profilePath, "utf8");

const profileContainsSource = profile.includes(getShellSourceCommand(shell));
const profileEndsWithSource = profile.trimEnd().endsWith(getShellSourceCommand(shell));
const shellSourceCommand = getShellSourceCommand(shell).trim();
const profileContainsSource = profile.includes(shellSourceCommand);
const profileEndsWithSource = profile.trimEnd().endsWith(shellSourceCommand);

if (!profileContainsSource) {
shellsWithoutPlugin.push(shell);
Expand Down Expand Up @@ -278,17 +279,17 @@ export const getShellSourceCommand = (shell: Shell): string => {
case Shell.Bash:
return `[ -f ~/.inshellisense/bash/init.sh ] && source ~/.inshellisense/bash/init.sh`;
case Shell.Powershell:
return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 } `;
return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 }`;
case Shell.Pwsh:
return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 } `;
return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 }`;
case Shell.Zsh:
return `[[ -f ~/.inshellisense/zsh/init.zsh ]] && source ~/.inshellisense/zsh/init.zsh`;
case Shell.Fish:
return `test -f ~/.inshellisense/fish/init.fish && source ~/.inshellisense/fish/init.fish`;
case Shell.Xonsh:
return `p"~/.inshellisense/xonsh/init.xsh".exists() && source "~/.inshellisense/xonsh/init.xsh"`;
case Shell.Nushell:
return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu } `;
return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu }`;
}
return "";
};
Expand Down

0 comments on commit aca796a

Please sign in to comment.