diff --git a/PSConfluencePublisher/Manifest.Tests.ps1 b/PSConfluencePublisher/Manifest.Tests.ps1 index 55f1760..ab54fc9 100755 --- a/PSConfluencePublisher/Manifest.Tests.ps1 +++ b/PSConfluencePublisher/Manifest.Tests.ps1 @@ -108,12 +108,12 @@ Describe 'Set-Manifest' ` Mock Copy-Item { #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 Set-Manifest ` @@ -139,11 +139,11 @@ Describe 'Set-Manifest' ` Mock Copy-Item { #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 diff --git a/PSConfluencePublisher/Manifest.psm1 b/PSConfluencePublisher/Manifest.psm1 index e69339f..7fa0a22 100755 --- a/PSConfluencePublisher/Manifest.psm1 +++ b/PSConfluencePublisher/Manifest.psm1 @@ -68,8 +68,22 @@ function Set-Manifest if ($Backup) { - #FIXME: this always assumes the current working directory - Copy-Item -Path $File -Destination "$(Split-Path -Leaf $File).bck" + $baseDir = Split-Path $File + + $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