@@ -575,10 +575,10 @@ function Test-CommandAvailable {
575575
576576function Install-Scoop {
577577 Write-InstallInfo ' Initializing...'
578- # Validate install parameters
579- Test-ValidateParameter
580578 # Check prerequisites
581579 Test-Prerequisite
580+ # Validate install parameters
581+ Test-ValidateParameter
582582 # Enable TLS 1.2
583583 Optimize-SecurityProtocol
584584
@@ -683,9 +683,6 @@ function Write-DebugInfo {
683683# Prepare variables
684684$IS_EXECUTED_FROM_IEX = ($null -eq $MyInvocation.MyCommand.Path )
685685
686- # Abort when the language mode is restricted
687- Test-LanguageMode
688-
689686# Scoop root directory
690687$SCOOP_DIR = $ScoopDir , $env: SCOOP , " $env: USERPROFILE \scoop" | Where-Object { -not [String ]::IsNullOrEmpty($_ ) } | Select-Object - First 1
691688# Scoop global apps directory
@@ -709,14 +706,18 @@ $SCOOP_MAIN_BUCKET_REPO = 'https://github.com/ScoopInstaller/Main/archive/master
709706$SCOOP_PACKAGE_GIT_REPO = ' https://github.com/ScoopInstaller/Scoop.git'
710707$SCOOP_MAIN_BUCKET_GIT_REPO = ' https://github.com/ScoopInstaller/Main.git'
711708
712- # Quit if anything goes wrong
713- $oldErrorActionPreference = $ErrorActionPreference
714- $ErrorActionPreference = ' Stop'
715-
716- # Logging debug info
717- Write-DebugInfo $PSBoundParameters
718- # Bootstrap function
719- Install-Scoop
720-
721- # Reset $ErrorActionPreference to original value
722- $ErrorActionPreference = $oldErrorActionPreference
709+ # The install flow triggers only when the script is executed directly, but
710+ # not when dot-sourced. Dot-sourcing the installer will not trigger the
711+ # installation, and only the functions will be loaded, e.g., for testing.
712+ # Downstreams can call `Install-Scoop` explicitly to start the installation.
713+ if ($MyInvocation.InvocationName -ne ' .' ) {
714+ $oldErrorActionPreference = $ErrorActionPreference
715+ try {
716+ $ErrorActionPreference = ' Stop'
717+ Test-LanguageMode
718+ Write-DebugInfo $PSBoundParameters
719+ Install-Scoop
720+ } finally {
721+ $ErrorActionPreference = $oldErrorActionPreference
722+ }
723+ }
0 commit comments