Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/InvokePlaster.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,15 @@ function Invoke-Plaster {
$srcRelPath = InterpolateAttributeValue $Node.source (GetErrorLocationFileAttrVal $Node.localName source)
$dstRelPath = InterpolateAttributeValue $Node.destination (GetErrorLocationFileAttrVal $Node.localName destination)

# We could choose to not check this if the condition eval'd to false
# but I think it is better to let the template author know they've broken the
# rules for any of the file directives (not just the ones they're testing/enabled).
$condition = $Node.condition
if ($condition -and !(EvaluateConditionAttribute $condition "'<$($Node.LocalName)>'")) {
$PSCmdlet.WriteDebug("Skipping $($Node.localName) '$srcRelPath' -> '$dstRelPath', condition evaluated to false.")
return
}

# Only validate paths for conditions that evaluate to true.
# The path may not be valid if it evaluates to false depending
# on whether or not conditional parameters are used in the template.
if ([System.IO.Path]::IsPathRooted($srcRelPath)) {
throw ($LocalizedData.ErrorPathMustBeRelativePath_F2 -f $srcRelPath,$Node.LocalName)
}
Expand All @@ -1068,12 +1074,6 @@ function Invoke-Plaster {
throw ($LocalizedData.ErrorPathMustBeRelativePath_F2 -f $dstRelPath,$Node.LocalName)
}

$condition = $Node.condition
if ($condition -and !(EvaluateConditionAttribute $condition "'<$($Node.LocalName)>'")) {
$PSCmdlet.WriteDebug("Skipping $($Node.localName) '$srcRelPath' -> '$dstRelPath', condition evaluated to false.")
return
}

# Check if node is the specialized, <templateFile> node.
# Only <templateFile> nodes expand templates and use the encoding attribute.
$isTemplateFile = $Node.localName -eq 'templateFile'
Expand Down