jscpd
Version:
Copy/paste detector for programming source code. Finds duplicated code in 224 languages, reports as HTML/JSON/SARIF/Markdown, fails CI over a duplication threshold. Rust engine, self-contained binary.
30 lines (26 loc) • 670 B
JavaScript
;
const { runJscpd } = require("./index");
let result;
try {
result = runJscpd(process.argv.slice(2), { stdio: "inherit" });
} catch (error) {
// Only the lookup errors are expected here. Anything else is a bug and
// keeps its stack.
if (error.code !== "JSCPD_NO_BINARY") {
throw error;
}
console.error(error.message);
process.exit(1);
}
if (result.error) {
if (result.error.code === "ENOENT") {
console.error(`jscpd: binary not found: ${result.error.path}`);
process.exit(1);
}
throw result.error;
}
if (result.signal) {
process.kill(process.pid, result.signal);
}
process.exit(result.status ?? 0);