Skip to content

Instantly share code, notes, and snippets.

@sheldonhull
Last active March 28, 2023 18:02
Show Gist options
  • Save sheldonhull/96642831fcbca2326bf52e8309769c20 to your computer and use it in GitHub Desktop.
Save sheldonhull/96642831fcbca2326bf52e8309769c20 to your computer and use it in GitHub Desktop.
configure-profile-for-aquaproj-support
if ($PSVERSIONTABLE.PSVersion -lt [version]'7.3.0'){
Write-Error "Update PowerShell. Try choco upgrade powershell-core -y, winget, or scoop install"
return
}
Write-Host "Updating CurrentUserAllHosts to have the required environment variables to properly load binaries managed by Aqua" -ForegroundColor Green
$ENV:PATH = (Join-Path $(go env GOPATH) 'bin'), $ENV:PATH -join [IO.Path]::PathSeparator
$ENV:XDG_DATA_HOME="${HOME}/.local/share
[string]$RootLocation = ''
if ($IsWindows) {
$RootLocation = (Join-Path $ENV:LOCALAPPDATA 'aquaproj-aqua')
} else {
$RootLocation = $ENV:AQUA_ROOT_DIR ?? (Join-Path (Join-Path $ENV:XDG_DATA_HOME 'aquaproj-aqua' 'bin') ?? (Join-Path "${HOME}/.local/share" 'aquaproj-aqua' 'bin')
}
$RootLocationWithBin = Join-Path $RootLocation 'bin'
$ENV:PATH = $RootLocationWithBin, $ENV:PATH -join [IO.Path]::PathSeparator
Write-Host "Prefixing PATH with: ${RootLocationWithBin}"

Test Binary Installed & Found

Test a binary is found (assuming golangci-lint is part of the aqua config).

try {
    &aqua install
    if (@(Get-Command 'golangc2i-lint').Count -eq 0){
        throw "couldn't find tooling installed by aqua?.... what do you did wrong?"
    }
    Write-Host ('✅ found golangci-lint: {0}' -f $(Get-Command 'golangci-lint').Source)
} catch {
    Write-Error "#fail"
}

If it's working, you can use the profile configuration in your profile. To use beyond VSCode, and make sure all terminals for pwsh recognize the command, update the following current user profile configuration.

  • Open profile: code -n $PROFILE.CurrentUserAllHosts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment