Skip to content

Commit 3ac2b5f

Browse files
corbobAdmiringWorm
authored andcommitted
(#1185) Always pass in hook scripts event if empty
When passing package parameters into chocolateyScriptRunner.ps1, if there are quotes, PowerShell can get confused. This ensures that we're specifying the new hook arguments and passing nothing if there should be nothing.
1 parent b7934fd commit 3ac2b5f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/chocolatey/infrastructure.app/services/PowershellService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ public string wrap_script_with_module(string script, IEnumerable<string> hookPre
194194

195195
private string get_script_arguments(string script, IEnumerable<string> hookPreScriptPathList, IEnumerable<string> hookPostScriptPathList, ChocolateyConfiguration config)
196196
{
197-
return "-packageScript '{0}' -installArguments '{1}' -packageParameters '{2}'{3}{4}{5}{6}".format_with(
197+
return "-packageScript '{0}' -installArguments '{1}' -packageParameters '{2}'{3}{4} -preRunHookScripts {5} -postRunHookScripts {6}".format_with(
198198
script,
199199
prepare_powershell_arguments(config.InstallArguments),
200200
prepare_powershell_arguments(config.PackageParameters),
201201
config.ForceX86 ? " -forceX86" : string.Empty,
202202
config.OverrideArguments ? " -overrideArgs" : string.Empty,
203-
hookPreScriptPathList.Any() ? " -preRunHookScripts {0}".format_with(string.Join(",", hookPreScriptPathList)) : string.Empty,
204-
hookPostScriptPathList.Any() ? " -postRunHookScripts {0}".format_with(string.Join(",", hookPostScriptPathList)) : string.Empty
203+
hookPreScriptPathList.Any() ? "{0}".format_with(string.Join(",", hookPreScriptPathList)) : "$null",
204+
hookPostScriptPathList.Any() ? "{0}".format_with(string.Join(",", hookPostScriptPathList)) : "$null"
205205
);
206206
}
207207

0 commit comments

Comments
 (0)