Skip to content

Commit 432e8ce

Browse files
author
James Brundage
committed
Core Inline Transpiler : Adding -LinePattern (fixes #197)
1 parent 679a45c commit 432e8ce

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Transpilers/Core/PipeScript.Inline.psx.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ $Parameter = @{},
7777
# An argument list.
7878
[Alias('Args')]
7979
[PSObject[]]
80-
$ArgumentList = @()
80+
$ArgumentList = @(),
81+
82+
# Some languages only allow single-line comments.
83+
# To work with these languages, provide a -LinePattern indicating what makes a comment
84+
# Only lines beginning with this pattern within -StartPattern and -EndPattern will be considered a script.
85+
[Regex]
86+
$LinePattern
8187
)
8288

8389
begin {
@@ -93,6 +99,11 @@ begin {
9399
return
94100
}
95101

102+
if ($LinePattern) {
103+
$pipeScriptLines = @($pipeScriptText -split '(?>\r\n|\n)')
104+
$pipeScriptText = $pipeScriptLines -match $LinePattern -replace $LinePattern -join [Environment]::Newline
105+
}
106+
96107
$InlineScriptBlock = [scriptblock]::Create($pipeScriptText)
97108
if (-not $InlineScriptBlock) {
98109
return

0 commit comments

Comments
 (0)