Skip to content

Commit

Permalink
feat: Invoke-Interpreter now uses Language.HasPowerShellInterpreter ( F…
Browse files Browse the repository at this point in the history
…ixes #904, Fixes #896 )
  • Loading branch information
StartAutomating authored and StartAutomating committed Feb 7, 2024
1 parent c3c7498 commit e9b2ca5
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Commands/Interpreters/Invoke-Interpreter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,28 @@ function Invoke-Interpreter {

$leadingArgs = @($leadingArgs)

# Now things get a little more complicated.

# Since many things that will interpret our arguments will _not_ be PowerShell, we want to conver them
$convertedArguments =
@(
if (
$interpreterCommand -isnot [ScriptBlock]
) {
$args |
. { process {
# Unless, of course, the interpreter is native PowerShell,
# which we can know if .HasPowerShellInterpreter is true
if ($interpreterForFile.HasPowerShellInterpreter) {
$args | . { process { $_ } }
} else {
# If it does not have a PowerShell interpreter,
$args |
. { process {
# Then non-string arguments should become JSON
if ($_ -isnot [string]) {
ConvertTo-Json -InputObject $_ -Depth 100
} else {
$_
}
} }
} else {
$args | . { process { $_ } }
})

if ($leadingArgs) {
if ($MyInvocation.ExpectingInput) {
$input | & $interpreterCommand @leadingArgs $invocationName @convertedArguments
Expand Down

0 comments on commit e9b2ca5

Please sign in to comment.