Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/code/CompressPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.PowerShell.PSResourceGet.UtilClasses;
using System.IO;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
Expand All @@ -15,6 +14,7 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
"PSResource",
SupportsShouldProcess = true)]
[Alias("cmres")]
[OutputType(typeof(FileInfo))]
public sealed class CompressPSResource : PSCmdlet
{
#region Parameters
Expand Down
3 changes: 2 additions & 1 deletion src/code/PublishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ private bool PackNupkg(string outputDir, string outputNupkgDir, string nuspecFil
{
if (PassThru)
{
_cmdletPassedIn.WriteObject(System.IO.Path.Combine(outputNupkgDir, _pkgName + "." + _pkgVersion.ToNormalizedString() + ".nupkg"));
var nupkgPath = System.IO.Path.Combine(outputNupkgDir, _pkgName + "." + _pkgVersion.ToNormalizedString() + ".nupkg");
_cmdletPassedIn.WriteObject(new FileInfo(nupkgPath));
}
_cmdletPassedIn.WriteVerbose("Successfully packed the resource into a .nupkg");
}
Expand Down
9 changes: 6 additions & 3 deletions test/PublishPSResourceTests/CompressPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,17 @@ Describe "Test Compress-PSResource" -tags 'CI' {
Test-Path -Path (Join-Path -Path $unzippedPath -ChildPath $testFile) | Should -Be $True
}

It "Compress-PSResource -PassThru returns the path to the nupkg" {
It "Compress-PSResource -PassThru returns a FileInfo object with the correct path" {
$version = "1.0.0"
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"

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

$expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
$nupkgPath | Should -Be $expectedPath
$fileInfoObject | Should -BeOfType 'System.IO.FileSystemInfo'
$fileInfoObject.FullName | Should -Be $expectedPath
$fileInfoObject.Extension | Should -Be '.nupkg'
$fileInfoObject.Name | Should -Be "$script:PublishModuleName.$version.nupkg"
}

<# Test for Signing the nupkg. Signing doesn't work
Expand Down
Loading