Skip to content

Commit 417da08

Browse files
authored
Merge branch 'master' into relativePathfix
2 parents 0840814 + 540b090 commit 417da08

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/code/CompressPSResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Microsoft.PowerShell.PSResourceGet.UtilClasses;
55
using System.IO;
6-
using System.Linq;
76
using System.Management.Automation;
87

98
namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
@@ -15,6 +14,7 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
1514
"PSResource",
1615
SupportsShouldProcess = true)]
1716
[Alias("cmres")]
17+
[OutputType(typeof(FileInfo))]
1818
public sealed class CompressPSResource : PSCmdlet
1919
{
2020
#region Parameters

src/code/PublishHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ private bool PackNupkg(string outputDir, string outputNupkgDir, string nuspecFil
571571
{
572572
if (PassThru)
573573
{
574-
_cmdletPassedIn.WriteObject(System.IO.Path.Combine(outputNupkgDir, _pkgName + "." + _pkgVersion.ToNormalizedString() + ".nupkg"));
574+
var nupkgPath = System.IO.Path.Combine(outputNupkgDir, _pkgName + "." + _pkgVersion.ToNormalizedString() + ".nupkg");
575+
_cmdletPassedIn.WriteObject(new FileInfo(nupkgPath));
575576
}
576577
_cmdletPassedIn.WriteVerbose("Successfully packed the resource into a .nupkg");
577578
}

test/PublishPSResourceTests/CompressPSResource.Tests.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ Describe "Test Compress-PSResource" -tags 'CI' {
204204
Remove-Item -Path $relativePath -Recurse -Force
205205
Remove-Item -Path $relativeDestination -Recurse -Force
206206
}
207-
208-
It "Compress-PSResource -PassThru returns the path to the nupkg" {
207+
208+
It "Compress-PSResource -PassThru returns a FileInfo object with the correct path" {
209209
$version = "1.0.0"
210210
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
211211

212-
$nupkgPath = Compress-PSResource -Path $script:PublishModuleBase -DestinationPath $script:repositoryPath -PassThru
212+
$fileInfoObject = Compress-PSResource -Path $script:PublishModuleBase -DestinationPath $script:repositoryPath -PassThru
213213

214214
$expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
215-
$nupkgPath | Should -Be $expectedPath
215+
$fileInfoObject | Should -BeOfType 'System.IO.FileSystemInfo'
216+
$fileInfoObject.FullName | Should -Be $expectedPath
217+
$fileInfoObject.Extension | Should -Be '.nupkg'
218+
$fileInfoObject.Name | Should -Be "$script:PublishModuleName.$version.nupkg"
216219
}
217220

218221
<# Test for Signing the nupkg. Signing doesn't work

0 commit comments

Comments
 (0)