saleor-dashboard/scripts/count-strict-null-check-errors.js

31 lines
703 B
JavaScript
Raw Permalink Normal View History

2020-02-25 14:28:14 +00:00
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
const fs = require("fs");
const readline = require("readline");
const updateSnapshot = process.argv.includes("-u");
const snapshotPath = ".travis/check-strict-null-errors.snapshot";
const shouldCount = /^src/;
2020-02-26 12:57:04 +00:00
let errors = [];
2020-02-25 14:28:14 +00:00
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on("line", line => {
if (shouldCount.test(line)) {
2020-02-26 12:57:04 +00:00
errors = [...errors, line];
2020-02-25 14:28:14 +00:00
}
});
rl.on("close", () => {
2020-02-26 12:57:04 +00:00
const output = errors.join("\n") + "\n";
2020-02-25 14:28:14 +00:00
if (updateSnapshot) {
2020-02-26 12:57:04 +00:00
fs.writeFileSync(snapshotPath, output);
2020-02-25 14:28:14 +00:00
} else {
2020-02-26 12:57:04 +00:00
console.log(output);
2020-02-25 14:28:14 +00:00
}
});