Skip to content

Commit

Permalink
(#1185) Re-add old powershell run host method
Browse files Browse the repository at this point in the history
Changing the interface or public methods are breaking changes which
we need to wait with implementing before the next major release.
As such, this commit adds back the old way of running the powershell
host by adding an overload with the original contract for the interface
that could possibly be used in other projects that makes use of the
Chocolatey.Lib library.

This overload has been made obsolete and will just call the new method
while setting any hook scripts as empty enumerables.
  • Loading branch information
AdmiringWorm committed Sep 23, 2022
1 parent 097b52f commit 2f17f8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -68,6 +68,10 @@ public interface IPowershellService
bool before_modify(ChocolateyConfiguration configuration, PackageResult packageResult);

void prepare_powershell_environment(IPackage package, ChocolateyConfiguration configuration, string packageDirectory);

[Obsolete("This version of running the powershell host do not support running additional hooks. Use the appropriate overload instead")]
PowerShellExecutionResults run_host(ChocolateyConfiguration config, string chocoPowerShellScript, Action<Pipeline> additionalActionsBeforeScript);

PowerShellExecutionResults run_host(ChocolateyConfiguration config, string chocoPowerShellScript, Action<Pipeline> additionalActionsBeforeScript, IEnumerable<string> hookPreScriptPathList, IEnumerable<string> hookPostScriptPathList);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -593,6 +593,12 @@ private void remove_assembly_resolver()
}
}

[Obsolete("This version of running the powershell host do not support running additional hooks. Use the appropriate overload instead")]
public PowerShellExecutionResults run_host(ChocolateyConfiguration config, string chocoPowershellScript, Action<Pipeline> additionalActionsBeforeScript)
{
return run_host(config, chocoPowershellScript, additionalActionsBeforeScript, Enumerable.Empty<string>(), Enumerable.Empty<string>());
}

public PowerShellExecutionResults run_host(ChocolateyConfiguration config, string chocoPowerShellScript, Action<Pipeline> additionalActionsBeforeScript, IEnumerable<string> hookPreScriptPathList, IEnumerable<string> hookPostScriptPathList)
{
// since we control output in the host, always set these true
Expand Down

0 comments on commit 2f17f8b

Please sign in to comment.