Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose env, save config #3

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ param(

$IS_EXECUTED_FROM_IEX = ($null -eq $MyInvocation.MyCommand.Path)
# Prepare environment variables
$SCOOP_DIR = $ScoopDir # Scoop root directory
$SCOOP_GLOBAL_DIR = $ScoopGlobalDir # Scoop global apps directory
$SCOOP_CACHE_DIR = $ScoopCacheDir # Scoop cache directory
$SCOOP_SHIMS_DIR = "$ScoopDir\shims" # Scoop shims directory
$SCOOP_APP_DIR = "$ScoopDir\apps\scoop\current" # Scoop itself directory
$SCOOP_CORE_BUCKET_DIR = "$ScoopDir\buckets\core" # Scoop core bucket directory
$SCOOP_DIR = if ($env:SCOOP) { $env:SCOOP } else { $ScoopDir } # Scoop root directory
$SCOOP_GLOBAL_DIR = if ($env:SCOOP_GLOBAL) { $env:SCOOP_GLOBAL } else { $ScoopGlobalDir } # Scoop global apps directory
$SCOOP_CACHE_DIR = if ($env:SCOOP_CACHE) { $env:SCOOP_CACHE } elseif ($env:SCOOP) { "$SCOOP_DIR\cache" } else { $ScoopCacheDir } # Scoop cache directory
$SCOOP_SHIMS_DIR = "$SCOOP_DIR\shims" # Scoop shims directory
$SCOOP_APP_DIR = "$SCOOP_DIR\apps\scoop\current" # Scoop itself directory
$SCOOP_CORE_BUCKET_DIR = "$SCOOP_DIR\buckets\core" # Scoop core bucket directory

# TODO: Use a specific version of Scoop and the core bucket
$SCOOP_PACKAGE_REPO = "https://github.com/lukesampson/scoop/archive/master.zip"
Expand Down Expand Up @@ -306,6 +306,13 @@ function Add-ShimsDirToPath {
}
}

function Add-Config {
scoop config 'rootPath' $SCOOP_DIR
scoop config 'cachePath' $SCOOP_CACHE_DIR
scoop config 'globalPath' $SCOOP_GLOBAL_DIR
scoop config 'lastUpdate' ([System.DateTime]::Now.ToString('o'))
}

function Install-Scoop {
Write-Output 'Initializing...'
Test-ValidateParameter
Expand Down Expand Up @@ -351,8 +358,8 @@ function Install-Scoop {

# Finially ensure scoop shims is in the PATH
Add-ShimsDirToPath
# Setup 'lastupdate' config
scoop config lastupdate ([System.DateTime]::Now.ToString('o'))
# Setup initial configuration of Scoop
Add-Config

Write-Host 'Scoop was installed successfully!' -f DarkGreen
Write-Output "Type 'scoop help' for instructions."
Expand Down