Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion src/code/CompressPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ public sealed class CompressPSResource : PSCmdlet
public string DestinationPath { get; set; }

/// <summary>
/// Bypasses validating a resource module manifest before publishing.
/// When specified, passes the full path of the nupkg through the pipeline.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Pass the full path of the nupkg through the pipeline")]
public SwitchParameter PassThru { get; set; }

/// <summary>
/// Bypasses validating a resource module manifest before compressing.
/// </summary>
[Parameter]
public SwitchParameter SkipModuleManifestValidate { get; set; }
Expand All @@ -61,6 +67,7 @@ protected override void BeginProcessing()
this,
Path,
DestinationPath,
PassThru,
SkipModuleManifestValidate);

_publishHelper.CheckAllParameterPaths();
Expand Down
8 changes: 7 additions & 1 deletion src/code/PublishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ internal enum CallerCmdlet
private string outputDir = string.Empty;
internal bool ScriptError = false;
internal bool ShouldProcess = true;
internal bool PassThru = false;

#endregion

#region Constructors

internal PublishHelper(PSCmdlet cmdlet, string path, string destinationPath, bool skipModuleManifestValidate)
internal PublishHelper(PSCmdlet cmdlet, string path, string destinationPath, bool passThru, bool skipModuleManifestValidate)
{
_callerCmdlet = CallerCmdlet.CompressPSResource;
_cmdOperation = "Compress";
_cmdletPassedIn = cmdlet;
Path = path;
DestinationPath = destinationPath;
PassThru = passThru;
SkipModuleManifestValidate = skipModuleManifestValidate;
outputDir = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString());
outputNupkgDir = destinationPath;
Expand Down Expand Up @@ -562,6 +564,10 @@ private bool PackNupkg(string outputDir, string outputNupkgDir, string nuspecFil

if (success)
{
if (PassThru)
{
_cmdletPassedIn.WriteObject(System.IO.Path.Combine(outputNupkgDir, _pkgName + "." + _pkgVersion.ToNormalizedString() + ".nupkg"));
}
_cmdletPassedIn.WriteVerbose("Successfully packed the resource into a .nupkg");
}
else
Expand Down
12 changes: 12 additions & 0 deletions test/PublishPSResourceTests/CompressPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ 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" {
Wait-Debugger
$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

$expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
$nupkgPath | Should -Be $expectedPath
}

<# Test for Signing the nupkg. Signing doesn't work
It "Compressed Module is able to be signed with a certificate" {
$version = "1.0.0"
Expand Down
Loading