Improve dead code detection (#22829)

pull/22930/head
Š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
1 changed files with 7 additions and 1 deletions

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