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
22 changes: 18 additions & 4 deletions PowerShellToolsPro.Packager.Test/ConfigDeserializerTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using PowerShellToolsPro.Packager.Config;
using System.Collections;
using System;
using System.Collections;
using System.IO;
using PowerShellToolsPro.Packager;
using Xunit;

namespace PowerShellToolsPro.Packager.Test
Expand All @@ -25,7 +28,7 @@ public void ShouldDeserializeListOfIgnoredModules()
}

[Fact]
public void ShouldDeserializeTimestampServer()
public void ShouldDeserializeTimestampServer()
{
var pathResolverMock = NSubstitute.Substitute.For<IPathResolver>();

Expand All @@ -39,8 +42,19 @@ public void ShouldDeserializeTimestampServer()

var config = deserializer.Deserialize(hashtable);

Assert.Equal("http://timestamp.digicert.com", config.Package.TimestampServer);
}
Assert.Equal("http://timestamp.digicert.com", config.Package.TimestampServer);
}

[Fact]
public void ShouldResolveRelativeRootAgainstWorkingDirectory()
{
var process = new PackageProcess();
process.Config.Root = @"scripts\entry.ps1";

new RootPathStage().Execute(process, null);

Assert.Equal(Path.Combine(Environment.CurrentDirectory, @"scripts\entry.ps1"), process.Config.Root);
}
}


Expand Down
19 changes: 19 additions & 0 deletions PowerShellToolsPro.Packager/PackageProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public PackageProcess()
_stages = new Stage[]
{
new ValidateStage(),
new RootPathStage(),
new OutputPathStage(),
new BundleStage(),
new CompileStage(),
Expand Down Expand Up @@ -272,6 +273,24 @@ public override StageResult Execute(PackageProcess process, StageResult previous
}
}

public class RootPathStage : Stage
{
public override bool ShouldExecute(PackageProcess process, StageResult previousStage)
{
return true;
}

public override StageResult Execute(PackageProcess process, StageResult previousStage)
{
if (!string.IsNullOrEmpty(process.Config.Root) && !Path.IsPathRooted(process.Config.Root))
{
process.Config.Root = Path.Combine(Environment.CurrentDirectory, process.Config.Root);
}

return Success(process.Script);
}
}

public class BundleStage : Stage
{
public override bool ShouldExecute(PackageProcess process, StageResult previousStage)
Expand Down
Loading