Skip to content

Commit 149e103

Browse files
committed
RegEx fixes
1 parent d6775bb commit 149e103

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PSAppDeployToolkit.Tools/Public/Convert-ADTDeployment.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,20 +263,20 @@ function Convert-ADTDeployment
263263
$hashtableContent = $hashtableAst.Right.Extent.Text
264264

265265
# Update the appScriptDate value to the current date
266-
$hashtableContent = $hashtableContent -replace "appScriptDate\s*=\s*'[^']+'", "appScriptDate = '$(Get-Date -Format "yyyy-MM-dd")'"
266+
$hashtableContent = $hashtableContent -replace "(?m)(^\s*appScriptDate\s*=)\s*'[^']+'", "`$1 '$(Get-Date -Format "yyyy-MM-dd")'"
267267

268268
# Copy each variable value from the input script to the hashtable
269269
foreach ($variableReplacement in $variableReplacements)
270270
{
271271
$assignmentAst = $inputScriptAst.Find({
272272
param ($ast)
273-
$ast -is [System.Management.Automation.Language.AssignmentStatementAst] -and $ast.Left.Extent.Text -match "^\[[^\]]+\]?\`$$variableReplacement$"
273+
$ast -is [System.Management.Automation.Language.AssignmentStatementAst] -and $ast.Left.Extent.Text -match "^(\[[^\]]+\])?\`$(adtSession\.)?$variableReplacement$"
274274
}, $true)
275275

276276
if ($assignmentAst)
277277
{
278278
$variableValue = $assignmentAst.Right.Extent.Text
279-
$hashtableContent = $hashtableContent -replace "$variableReplacement\s*=\s*'[^']*'", "$variableReplacement = $variableValue"
279+
$hashtableContent = $hashtableContent -replace "(?m)(^\s*$variableReplacement\s*=)\s*'[^']*'", "`$1 $variableValue"
280280
}
281281
}
282282

0 commit comments

Comments
 (0)