mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-22 13:07:58 +01:00
8bc3f7fe36
This code serves as an application framework of sorts and is totally not stolen from some of my other projects.
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
"use strict";
|
|
|
|
const fs = require("fs-extra");
|
|
const path = require("path");
|
|
const readline = require("readline");
|
|
const klaw = require("klaw");
|
|
const WritableStream = require("stream").Writable;
|
|
|
|
const outstream = new WritableStream();
|
|
|
|
if (!process.argv[2]) throw new Error("No path to check given");
|
|
|
|
let found = 0;
|
|
klaw(process.argv[2], {
|
|
filter: p => !path.relative(process.argv[2], p).includes("node_modules") && p !== __filename
|
|
})
|
|
.on("data", async item => {
|
|
if (item.stats.isFile()) {
|
|
if (![
|
|
".js",
|
|
".ts",
|
|
".mjs",
|
|
".cjs"
|
|
].includes(path.parse(item.path).ext.toLowerCase())) return;
|
|
const rl = readline.createInterface({
|
|
input: fs.createReadStream(item.path),
|
|
output: outstream,
|
|
terminal: false
|
|
});
|
|
let lnCnt = 0;
|
|
rl.on("line", line => {
|
|
lnCnt++;
|
|
const index = line.search(/TODO:/);
|
|
if (index !== -1) {
|
|
console.log(`${path.relative(process.argv[2], item.path)}:${lnCnt}:${index + 1}\t${line}`);
|
|
found++;
|
|
}
|
|
});
|
|
}
|
|
})
|
|
.on("end", () => {
|
|
if (found) {
|
|
console.error(`${found} TODO: have been found in the code`);
|
|
process.exit(1);
|
|
}
|
|
});
|