From f61e0768d25ae74f8b59ba32e8d4c216ec76c596 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 7 Nov 2024 14:31:34 +0000 Subject: [PATCH] Handle scoop completion gracefully --- install.ps1 | 8 ++++++++ profile.ps1 | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index ebc08bb..bc78885 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,3 +1,11 @@ +if (Get-Command scoop.ps1 -ErrorAction SilentlyContinue) { + $ScoopCompletion = "$($(Get-Item $(Get-Command scoop.ps1).Path).Directory.Parent.FullName)\modules\scoop-completion" + if (!(Test-Path $ScoopCompletion)) { + scoop bucket add extras + scoop install scoop-completion + } +} + if (!(Test-Path -PathType Container $env:LOCALAPPDATA\layouts)) { New-Item -ItemType Directory -Path $env:LOCALAPPDATA\layouts Write-Output "changed: created directory $env:LOCALAPPDATA\layouts" diff --git a/profile.ps1 b/profile.ps1 index cf1e01f..f5a5a80 100644 --- a/profile.ps1 +++ b/profile.ps1 @@ -8,7 +8,10 @@ $GitPromptSettings.BeforeStatus = "" $GitPromptSettings.AfterStatus = "" # Enable Scoop completions. if (Get-Command scoop.ps1 -ErrorAction SilentlyContinue) { - Import-Module "$($(Get-Item $(Get-Command scoop.ps1).Path).Directory.Parent.FullName)\modules\scoop-completion" + $ScoopCompletion = "$($(Get-Item $(Get-Command scoop.ps1).Path).Directory.Parent.FullName)\modules\scoop-completion" + if (Test-Path $ScoopCompletion) { + Import-Module $ScoopCompletion + } } # Enable Chocolatey completions. Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"