Improve dead code detection (#22829)

This commit is contained in:
Šimon Brandner 2022-07-25 11:35:48 +02:00 committed by GitHub
parent b3b8e2e0a2
commit ee3b9c3310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,15 +4,21 @@
const fs = require("fs");
const { exec } = require("node:child_process");
const includeJSSDK = process.argv.includes("--include-js-sdk");
const ignore = [];
ignore.push(...Object.values(JSON.parse(fs.readFileSync(`${__dirname}/../components.json`))));
ignore.push("/index.ts");
// We ignore js-sdk by default as it may export for other non element-web projects
if (!includeJSSDK) ignore.push("matrix-js-sdk");
const command = `yarn ts-prune --ignore "${ignore.join("|")}" | grep -v "(used in module)"`;
exec(command, (error, stdout) => {
exec(command, (error, stdout, stderr) => {
if (error) throw error;
// We have to do this as piping the output of ts-prune causes the return
// code to be 0
if (stderr) throw Error(stderr);
let lines = stdout.split("\n");
// Remove the first line as that is the command that was being run and we