fix(manifest): allow for non cwd backups
- fix a fault where the backup file was only generated within the current directory - fix a fault in Pester tests, where the parameter was wrongly used as the script block for assertion.
This commit is contained in:
parent
8533997b68
commit
3c7ba0e2a4
2 changed files with 23 additions and 9 deletions
|
|
@ -108,12 +108,12 @@ Describe 'Set-Manifest' `
|
||||||
|
|
||||||
Mock Copy-Item {
|
Mock Copy-Item {
|
||||||
#FIXME: the scope is completely wrong
|
#FIXME: the scope is completely wrong
|
||||||
Should -Invoke -CommandName 'Copy-Item' -Exactly -Times 1
|
Should -Invoke -CommandName 'Copy-Item' -Exactly -Times 1 `
|
||||||
|
|
||||||
$args[1] | Should -Be 'foobar.x'
|
$Path | Should -Be 'foobar.x'
|
||||||
|
|
||||||
$args[3] | Should -Be 'foobar.x.bck'
|
$Destination | Should -Be 'foobar.x.bck'
|
||||||
}
|
}
|
||||||
|
|
||||||
#mocking Get-Content, therefore file name can be bogus
|
#mocking Get-Content, therefore file name can be bogus
|
||||||
Set-Manifest `
|
Set-Manifest `
|
||||||
|
|
@ -139,11 +139,11 @@ Describe 'Set-Manifest' `
|
||||||
|
|
||||||
Mock Copy-Item {
|
Mock Copy-Item {
|
||||||
#FIXME: the scope is completely wrong
|
#FIXME: the scope is completely wrong
|
||||||
Should -Invoke -CommandName 'Copy-Item' -Exactly -Times 1
|
Should -Invoke -CommandName 'Copy-Item' -Exactly -Times 1 `
|
||||||
|
|
||||||
$args[1] | Should -Be 'foo/bar/foobar.x'
|
$Path | Should -Be 'foo/bar/foobar.x'
|
||||||
|
|
||||||
$args[3] | Should -Be 'foo/bar/foobar.x.bck'
|
$Destination | Should -Be 'foo/bar/foobar.x.bck'
|
||||||
}
|
}
|
||||||
|
|
||||||
#mocking Get-Content, therefore file name can be bogus
|
#mocking Get-Content, therefore file name can be bogus
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,22 @@ function Set-Manifest
|
||||||
|
|
||||||
if ($Backup)
|
if ($Backup)
|
||||||
{
|
{
|
||||||
#FIXME: this always assumes the current working directory
|
$baseDir = Split-Path $File
|
||||||
Copy-Item -Path $File -Destination "$(Split-Path -Leaf $File).bck"
|
|
||||||
|
$baseName = "$(Split-Path -Leaf $File).bck"
|
||||||
|
|
||||||
|
#FIXME: this should be handled without an explicit condition
|
||||||
|
if ($baseDir)
|
||||||
|
{
|
||||||
|
$path = Join-Path $baseDir $baseName
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$path = $baseName
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item -Path $File -Destination $path
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-Content -Path $File -Value $raw
|
Set-Content -Path $File -Value $raw
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue