Skip to content

Commit

Permalink
pr-fix: update to warning and not stop the script
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Dec 3, 2021
1 parent 2e6987c commit f6071fc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Arcus.Scripting.ARM/Scripts/Inject-ArmContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function InjectFile {
if ($instructionParts.Length -gt 1) {
$optionParts = $instructionParts | select -Skip 1

if ($optionParts.Contains("ReplaceSpecialChars")){
if ($optionParts.Contains("ReplaceSpecialChars")) {
Write-Host "`t Replacing special characters"

# Replace newline characters with literal equivalents
Expand All @@ -81,21 +81,21 @@ function InjectFile {
$newString = $newString -replace '(?<!\\)"', '\"'
}


if ($optionParts.Contains("InjectAsJsonObject")){
try{
if ($optionParts.Contains("InjectAsJsonObject")) {
try {
# Test if content is valid JSON
Write-Host "Test if valid JSON: $newString"
ConvertFrom-Json $newString

$surroundContentWithDoubleQuotes = $False
}
catch{
Write-Error "Content to inject cannot be parsed as a JSON object!"
catch {
Write-Warning "Content to inject cannot be parsed as a JSON object!"
}
}
}

if ($surroundContentWithDoubleQuotes){
if ($surroundContentWithDoubleQuotes) {
Write-Host "`t Surrounding content in double quotes"

$newString = '"' + $newString + '"'
Expand Down

0 comments on commit f6071fc

Please sign in to comment.