File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed
Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change 11<#
22. SYNOPSIS
3- defines a variable
3+ Defines a variable
44. DESCRIPTION
5- Defines a variable using a value provided during a build
5+ Defines a variable using a value provided at build time.
66. EXAMPLE
77 {
88 [Define(Value={Get-Random})]$RandomNumber
@@ -25,11 +25,6 @@ $Value,
2525[Management.Automation.Language.VariableExpressionast ]
2626$VariableAst ,
2727
28- # A scriptblock the definition will be applied to
29- [Parameter (Mandatory , ParameterSetName = ' ScriptBlock' , ValueFromPipeline )]
30- [scriptblock ]
31- $ScriptBlock = {},
32-
3328# The name of the variable. If define is applied as an attribute of a variable, this does not need to be provided.
3429[Alias (' Name' )]
3530[string ]
@@ -122,14 +117,14 @@ $($value | ConvertTo-Json -Depth 100)
122117 " begin"
123118 } elseif ($scriptBlock.Ast.processblock.Statements ) {
124119 " process"
125- } else {
126- " "
120+ } else { ' ' }
121+ $toCreate =
122+ if ($blockName ) {
123+ " $blockName {`$ $VariableName =$definedValue }"
127124 }
128- if ($blockName ) {
129- [ScriptBlock ]::Create(" $blockName {'$' + $VariableName + ' = ' + $definedValue }" ), $ScriptBlock | Join-PipeScript
130- }
131- else {
132- [ScriptBlock ]::Create(' $' + $VariableName + ' = ' + $definedValue ), $ScriptBlock | Join-PipeScript
133- }
125+ else {
126+ " param() `$ $VariableName = $definedValue "
127+ }
128+ [scriptblock ]::Create($toCreate ), $scriptblock | Join-PipeScript
134129 }
135130}
You can’t perform that action at this time.
0 commit comments