@@ -99,12 +99,34 @@ function clean {
99
99
[Switch ]$Packages
100
100
)
101
101
102
+ $DeleteMe = Join-Path $Env: Temp " Delete This Folder"
103
+
104
+ while (Test-Path $DeleteMe - PathType Leaf) {
105
+ $DeleteMe = $DeleteMe + " !"
106
+ }
107
+
108
+ if (Test-Path $DeleteMe - PathType Container) {
109
+ Remove-Item $DeleteMe - Recurse - Force - ErrorAction SilentlyContinue
110
+ }
111
+ $DeleteMe = Join-Path $DeleteMe ([Guid ]::NewGuid().Guid)
112
+ $null = New-Item $DeleteMe - Type Directory - Force
113
+
102
114
Trace-Message " OUTPUT Release Path: $ReleasePath "
103
115
if (Test-Path $ReleasePath ) {
104
116
Trace-Message " Clean up old build"
105
- Trace-Message " DELETE $ReleasePath \"
106
- Remove-Item $ReleasePath - Recurse - Force - ErrorAction Continue
117
+ Trace-Message " REMOVE $ReleasePath \"
118
+ Push-Location $ReleasePath
119
+ foreach ($file in Get-ChildItem $ReleasePath - Recurse | Where-Object { ! $_.PSIsContainer }) {
120
+ $RelPath = Resolve-Path $file.FullName - Relative | Split-Path
121
+ $Destination = Join-Path $DeleteMe $RelPath
122
+ $Destination = (New-Item $Destination - Type Directory - Force).FullName
123
+ Trace-Message " (re)move $RelPath to $Destination "
124
+ Move-Item $file.FullName - Force - Destination $Destination
125
+ }
126
+ Pop-Location
127
+ Remove-Item $ReleasePath - Force - Recurse
107
128
}
129
+
108
130
if (Test-Path $Path \packages) {
109
131
Trace-Message " DELETE $Path \packages"
110
132
# force reinstall by cleaning the old ones
@@ -165,7 +187,7 @@ function update {
165
187
foreach ($manifest in Get-ChildItem $Script :SourcePath - filter * .psd1 - Recurse) {
166
188
foreach ($Dependency in (Get-Module $manifest.FullName - ListAvailable - ErrorAction SilentlyContinue).RequiredModules) {
167
189
if (! (Get-Module $Dependency.Name - ListAvailable - EA 0 )) {
168
- Install-Module - Name $Dependency.Name - AllowClobber - Force - SkipPublisherCheck
190
+ Install-Module - Name $Dependency.Name - AllowClobber - Force - SkipPublisherCheck - Scope CurrentUser
169
191
}
170
192
}
171
193
}
@@ -302,18 +324,18 @@ function test {
302
324
Set-Content " $TestPath \.Do.Not.COMMIT.This.Steps.ps1" " Import-Module $ReleasePath \${ModuleName} .psd1 -Force"
303
325
304
326
# Show the commands they would have to run to get these results:
305
- Write-Host $ (prompt) - NoNewLine
327
+ Write-Host " C:\PS> " - NoNewLine
306
328
Write-Host Import-Module $ReleasePath \${ModuleName}.psd1 - Force
307
- Write-Host $ (prompt) - NoNewLine
329
+ Write-Host " C:\PS> " - NoNewLine
308
330
309
331
# TODO: Update dependency to Pester 4.0 and use just Invoke-Pester
310
332
if (Get-Command Invoke-Gherkin - ErrorAction SilentlyContinue) {
311
333
Write-Host Invoke-Gherkin - Path $TestPath - CodeCoverage " $ReleasePath \*.psm1" - PassThru @Options
312
334
$TestResults = Invoke-Gherkin - Path $TestPath - CodeCoverage " $ReleasePath \*.psm1" - PassThru @Options
313
335
}
314
336
315
- # Write-Host Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
316
- # $TestResults = Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
337
+ Write-Host Invoke-Pester - Path $TestPath - CodeCoverage " $ReleasePath \*.psm1" - PassThru @Options
338
+ $TestResults = Invoke-Pester - Path $TestPath - CodeCoverage " $ReleasePath \*.psm1" - PassThru @Options
317
339
318
340
Remove-Module $ModuleName - ErrorAction SilentlyContinue
319
341
Remove-Item " $TestPath \.Do.Not.COMMIT.This.Steps.ps1"
0 commit comments