Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #59 from jsnape/master

Ignore the $WhatIfPreference and $ConfirmPreference variables
  • Loading branch information...
commit 5a6d7d27da26d63228616c9291bfb74c1da3938a 2 parents 4530c58 + 266b80f
@damianh damianh authored
View
3  .gitignore
@@ -1,2 +1,3 @@
[B|b]in
-*.nupkg
+*.nupkg
+Thumbs.db
View
25 psake.psm1
@@ -342,9 +342,9 @@ function Invoke-psake {
foreach ($key in $parameters.keys) {
if (test-path "variable:\$key") {
- set-item -path "variable:\$key" -value $parameters.$key | out-null
+ set-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null
} else {
- new-item -path "variable:\$key" -value $parameters.$key | out-null
+ new-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null
}
}
@@ -355,7 +355,7 @@ function Invoke-psake {
foreach ($key in $properties.keys) {
if (test-path "variable:\$key") {
- set-item -path "variable:\$key" -value $properties.$key | out-null
+ set-item -path "variable:\$key" -value $properties.$key -WhatIf:$false -Confirm:$false | out-null
}
}
@@ -398,16 +398,15 @@ function Invoke-psake {
$psake.build_success = $false
- if (!$psake.run_by_psake_build_tester) {
- # if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception
- # so that the parent script will fail otherwise the parent script will report a successful build
- $inNestedScope = ($psake.context.count -gt 1)
- if ( $inNestedScope ) {
- throw $_
- } else {
- WriteColoredOutput $error_message -foregroundcolor Red
- }
-
+ # if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception
+ # so that the parent script will fail otherwise the parent script will report a successful build
+ $inNestedScope = ($psake.context.count -gt 1)
+ if ( $inNestedScope ) {
+ throw $_
+ } else {
+ if (!$psake.run_by_psake_build_tester) {
+ WriteColoredOutput $error_message -foregroundcolor Red
+ }
}
} finally {
CleanupEnvironment
View
5 specs/nested/always_fail.ps1
@@ -0,0 +1,5 @@
+Task default -Depends AlwaysFail
+
+Task AlwaysFail {
+ Assert $false "This should always fail."
+}
View
5 specs/nested/whatifpreference.ps1
@@ -0,0 +1,5 @@
+Task default -Depends WhatIfCheck
+
+Task WhatIfCheck {
+ Assert ($p1 -eq 'whatifcheck') '$p1 was not whatifcheck'
+}
View
5 specs/nested_builds_that_fail_should_fail.ps1
@@ -0,0 +1,5 @@
+Task default -Depends RunAlwaysFail
+
+Task RunAlwaysFail {
+ Invoke-psake .\nested\always_fail.ps1
+}
View
15 specs/whatif_preference_should_pass.ps1
@@ -0,0 +1,15 @@
+Task default -Depends RunWhatIf
+
+Task RunWhatIf {
+ try {
+ ## Setup the -whatif flag globally
+ $global:WhatIfPreference = $true
+
+ ## Ensure that psake ends up by calling something with -whatif e.g. Set-Item
+ $parameters = @{p1='whatifcheck';}
+
+ Invoke-psake .\nested\whatifpreference.ps1 -parameters $parameters
+ } finally {
+ $global:WhatIfPreference = $false
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.