Minor tweaks for windows env

This commit is contained in:
GalSz (Varnois VDI) 2021-12-13 23:23:45 -05:00
parent 1c4e9feb1f
commit c5311de65a
3 changed files with 18 additions and 13 deletions

View File

@ -452,7 +452,7 @@ function _Init {
} }
$_profiles | Foreach-Object { $_profiles | Foreach-Object {
$local:p = Invoke-Expression "`$profile.$_" $local:p = $profile."$_"
if( -not $p ) { $p = $_ } if( -not $p ) { $p = $_ }
$local:profileContent = $randomSeed; $local:profileContent = $randomSeed;
$local:exists = Test-Path $p $local:exists = Test-Path $p

View File

@ -1,5 +1,12 @@
param([switch]$IgnoreSystem,[switch]$MissingOnly,[switch]$GenInstallCode) param(
[switch]$IgnoreSystem,
[switch]$MissingOnly,
[switch]$GenInstallCode,
[switch]$UserScope
)
$local:scopeStr = ""
if( $UserScope ) { $scopeStr = " -Scope CurrentUser" }
$local:currentSys = @('Always') + ([SystemName]::_GetValidValues('',$true,$true)); $local:currentSys = @('Always') + ([SystemName]::_GetValidValues('',$true,$true));
$local:oldPSGet = Get-Module PowerShellGet -ListAvailable -ErrorAction SilentlyContinue | $local:oldPSGet = Get-Module PowerShellGet -ListAvailable -ErrorAction SilentlyContinue |
@ -11,9 +18,9 @@ if( $local:oldPSGet ) {
"PowerShellGet is an old version ($($oldPSGet.Version)), the following code should upgrade it" "PowerShellGet is an old version ($($oldPSGet.Version)), the following code should upgrade it"
, "# Set-PSRepository -Name PSGallery -InstallationPolicy Trusted" , "# Set-PSRepository -Name PSGallery -InstallationPolicy Trusted"
, " [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" , " [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
, " Install-PackageProvider -Name NuGet -Force" , " Install-PackageProvider -Name NuGet -Force${scopeStr}"
, " Remove-Module PowerShellGet" , " Remove-Module PowerShellGet"
, " Install-Module -Name PowerShellGet -Force" , " Install-Module -Name PowerShellGet -Force${scopeStr}"
, " Update-Module -Name PowerShellGet" , " Update-Module -Name PowerShellGet"
) -join "`n" ) ) -join "`n" )
} }
@ -41,5 +48,8 @@ if( $GenInstallCode ) {
} | ForEach-Object { } | ForEach-Object {
if( -not $GenInstallCode ) { return $_ } if( -not $GenInstallCode ) { return $_ }
"Write-Host -ForegroundColor Cyan 'Installing $_...';" "Write-Host -ForegroundColor Cyan 'Installing $_...';"
"Install-Module $_ -AllowClobber" "Install-Module $_ -AllowClobber${scopeStr}"
} }
if( $GenInstallCode ) {
". Reload-MyScripts"
}

View File

@ -6,14 +6,9 @@ if( -not (Test-Path variable:global:ScoopRefreshed) ) {
$global:ScoopRefreshed = [SessionData]::Get("ScoopRefreshed",$false) $global:ScoopRefreshed = [SessionData]::Get("ScoopRefreshed",$false)
if( -not $ScoopRefreshed ) { if( -not $ScoopRefreshed ) {
if( Test-Path (Join-Path $env:SCOOP last-scoop-refresh.clixml) ) { if($Host.Name -ne 'Visual Studio Code Host' ) {
if($Host.Name -ne 'Visual Studio Code Host' ) { scoop refresh
scoop refresh [SessionData]::Set("ScoopRefreshed",$true)
[SessionData]::Set("ScoopRefreshed",$true)
}
} else {
Write-Warning ("No recorded time for last 'scoop refresh', to remedy, run 'scoop refresh' at least once manually." +
"`nIf the issue still persists, please run 'scoop alias-update' to update to latest refresh code, and try again.")
} }
} }