Skip to content

Commit 6bd8284

Browse files
author
James Brundage
committed
Adding pipeline and interactive support to 'new' (Fixes #265, re #263)
1 parent 05a03e4 commit 6bd8284

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Transpilers/Keywords/New.psx.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
$CommandAst = $_
3939
return ($commandAst -and $CommandAst.CommandElements[0].Value -eq 'new')
4040
})]
41+
[Reflection.AssemblyMetadata("PipeScript.Keyword",$true)]
4142
param(
4243
[Parameter(Mandatory,ValueFromPipeline)]
4344
[Management.Automation.Language.CommandAst]
@@ -164,8 +165,15 @@ process {
164165
$newNew = "`$($newNew)"
165166
}
166167

168+
167169
if ($newNew) {
168-
[scriptblock]::Create($newNew)
170+
if ($CommandAst.IsPiped) {
171+
[scriptblock]::create(". { process {
172+
$newNew
173+
} }")
174+
} else {
175+
[scriptblock]::Create($newNew)
176+
}
169177
} else {
170178
Write-Error "Unable to create '$newTypeName'"
171179
return

0 commit comments

Comments
 (0)