File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ function Install-ModuleFast {
232
232
| Out-File - FilePath $CILockFilePath - Encoding UTF8
233
233
}
234
234
}
235
- clean {
235
+ CLEAN {
236
236
$cancelSource.Dispose ()
237
237
}
238
238
}
@@ -300,9 +300,10 @@ function Get-ModuleFastPlan {
300
300
$ErrorActionPreference = ' Stop'
301
301
[HashSet [ModuleFastSpec ]]$modulesToResolve = @ ()
302
302
303
- # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient
304
- $cancelTokenSource = [CancellationTokenSource ]::new()
305
- $CancellationToken ?? = $cancelTokenSource.Token
303
+ # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient.
304
+ # We get a child so that a cancellation here does not affect any upstream commands
305
+ $cancelTokenSource = $CancellationToken ? [CancellationTokenSource ]::CreateLinkedTokenSource($CancellationToken ) : [CancellationTokenSource ]::new()
306
+ $CancellationToken = $cancelTokenSource.Token
306
307
307
308
# We pass this splat to all our HTTP requests to cut down on boilerplate
308
309
$httpContext = @ {
@@ -621,6 +622,12 @@ function Install-ModuleFastHelper {
621
622
[HttpClient ]$HttpClient ,
622
623
[switch ]$Update
623
624
)
625
+ BEGIN {
626
+ # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient.
627
+ # We get a child so that a cancellation here does not affect any upstream commands
628
+ $cancelTokenSource = $CancellationToken ? [CancellationTokenSource ]::CreateLinkedTokenSource($CancellationToken ) : [CancellationTokenSource ]::new()
629
+ $CancellationToken = $cancelTokenSource.Token
630
+ }
624
631
END {
625
632
$ErrorActionPreference = ' Stop'
626
633
You can’t perform that action at this time.
0 commit comments