Created
August 16, 2023 18:09
-
-
Save detain/e3809bf129bf726f0eec2fa6fb89568f to your computer and use it in GitHub Desktop.
Run tsc/vue-tsc converting the output to brief/easy to read JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
npm i -g @aivenio/tsc-output-parser; | |
echo "Running vue-tsc and parsing output into errors.json"; | |
npx vue-tsc --strict --noEmit | npx tsc-output-parser > errors.json; | |
echo "remapping errors.json"; | |
echo '<?php | |
$errors = []; | |
$jsonOpts = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; | |
$json = json_decode(file_get_contents("errors.json"),true); | |
foreach ($json as $row) { | |
$errors[] = [ | |
"path" => $row["value"]["path"]["value"], | |
"line" => $row["value"]["cursor"]["value"]["line"], | |
"col" => $row["value"]["cursor"]["value"]["col"], | |
"code" => $row["value"]["tsError"]["value"]["errorString"], | |
"text" => trim($row["value"]["message"]["value"]) | |
]; | |
} | |
file_put_contents("errors.json", json_encode($errors, $jsonOpts));' | php; | |
sed -e s#"\({\"path\":\)"#"\n \1"#g -e s#"}]$"#"}\n]"#g -i errors.json; | |
echo "done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will generate a file errors.json with contents that look something like this: