|
60 | 60 | fi |
61 | 61 |
|
62 | 62 | # Update conditional markup in place |
63 | | - sed -i 's/ifdef::.*/ifdef::temp-ifdef[]/; s/ifeval::.*/ifeval::["{temp-ifeval}" == "temp"]/; s/ifndef::.*/ifndef::temp-ifndef[]/; s/endif::.*/endif::[]/;' "$FILE" |
| 63 | + if [[ "$OSTYPE" == "darwin"* ]]; then |
| 64 | + sed -i '' 's/ifdef::.*/ifdef::temp-ifdef[]/; s/ifeval::.*/ifeval::["{temp-ifeval}" == "temp"]/; s/ifndef::.*/ifndef::temp-ifndef[]/; s/endif::.*/endif::[]/;' "$FILE" |
| 65 | + else |
| 66 | + sed -i 's/ifdef::.*/ifdef::temp-ifdef[]/; s/ifeval::.*/ifeval::["{temp-ifeval}" == "temp"]/; s/ifndef::.*/ifndef::temp-ifndef[]/; s/endif::.*/endif::[]/;' "$FILE" |
| 67 | + fi |
64 | 68 |
|
65 | 69 | # Parse for vale errors |
66 | 70 | vale_json=$(vale --minAlertLevel=error --output=.vale/templates/bot-comment-output.tmpl --config="$INI" "$FILE" | jq) |
|
120 | 124 |
|
121 | 125 | # Check if there is a comma in the number pairing before @@ |
122 | 126 | if [[ $line =~ \+.*\,.*\ @@ ]]; then |
123 | | - # There are comma separated numbers before closing @@. Grab the number before the comma as the diff_start_line, after the comma is the added_lines. |
124 | | - added_lines=$(echo "$line" | grep -oP '\d+\s+@@' | grep -oP '\d+') |
| 127 | + # There are comma separated numbers before closing @@. Grab the number before the comma as the diff_start_line, after the comma is the added_lines. |
| 128 | + if [[ "$OSTYPE" == "darwin"* ]]; then |
| 129 | + added_lines=$(echo "$line" | grep -oE '[0-9]+[[:space:]]+@@' | grep -oE '[0-9]+') |
| 130 | + else |
| 131 | + added_lines=$(echo "$line" | grep -oP '\d+\s+@@' | grep -oP '\d+') |
| 132 | + fi |
125 | 133 | diff_start_line=$(echo "$line" | awk -F'+' '{print $2}' | awk -F',' '{print $1}') |
126 | 134 | else |
127 | 135 | # There are no comma seperated numbers. Consider the number after the plus as diff_start_line with no added lines - this means there's a modification on a single line |
128 | 136 | added_lines=0 |
129 | | - diff_start_line=$(echo "$line" | grep -oP '\+\d+\s+@@' | grep -oP '\d+') |
| 137 | + if [[ "$OSTYPE" == "darwin"* ]]; then |
| 138 | + diff_start_line=$(echo "$line" | grep -oE '\+[0-9]+[[:space:]]+@@' | grep -oE '[0-9]+') |
| 139 | + else |
| 140 | + diff_start_line=$(echo "$line" | grep -oP '\+\d+\s+@@' | grep -oP '\d+') |
| 141 | + fi |
130 | 142 | fi |
131 | 143 |
|
132 | 144 | # If the last_number is 0, disregard the hunk and move to the next hunk as zero lines were modified (deletions only) |
|
0 commit comments