Skip to content

Commit

Permalink
Changed from environment variable to config
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Feb 27, 2024
1 parent 117cfad commit 1765925
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/core.ps1
Expand Up @@ -740,10 +740,11 @@ public static extern IntPtr SendMessageTimeout(

function env($name, $global, $val = '__get') {
if(-not $name) {
$name = [environment]::getEnvironmentVariable("SCOOP_ENV", "User")
if(-not $name) {
$name = 'PATH'
}
$name = $scoop_path_env
}

if(-not $name) {
throw "Unable to evaluate path environment variable. Please set or remove PATH_ENV in your config.json."
}

$RegisterKey = if ($global) {
Expand All @@ -755,7 +756,7 @@ function env($name, $global, $val = '__get') {

if ($val -eq '__get') {
$RegistryValueOption = [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames
$EnvRegisterKey.GetValue($name, $null, $RegistryValueOption)
$EnvRegisterKey.GetValue($name, $null, $RegistryValueOption) + ""
} elseif ($val -eq $null) {
try { $EnvRegisterKey.DeleteValue($name) } catch { }
Publish-Env
Expand Down Expand Up @@ -1422,6 +1423,8 @@ if ($pathExpected) {
}
$scoopConfig = load_cfg $configFile

$scoop_path_env = get_config PATH_ENV 'PATH'

# NOTE Scoop config file migration. Remove this after 2023/6/30
if ($scoopConfig -and $scoopConfig.PSObject.Properties.Name -contains 'lastUpdate') {
$newConfigNames = @{
Expand Down

0 comments on commit 1765925

Please sign in to comment.