Improve dead code detection (#22829)
parent
b3b8e2e0a2
commit
ee3b9c3310
|
@ -4,15 +4,21 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { exec } = require("node:child_process");
|
const { exec } = require("node:child_process");
|
||||||
|
|
||||||
|
const includeJSSDK = process.argv.includes("--include-js-sdk");
|
||||||
const ignore = [];
|
const ignore = [];
|
||||||
|
|
||||||
ignore.push(...Object.values(JSON.parse(fs.readFileSync(`${__dirname}/../components.json`))));
|
ignore.push(...Object.values(JSON.parse(fs.readFileSync(`${__dirname}/../components.json`))));
|
||||||
ignore.push("/index.ts");
|
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)"`;
|
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;
|
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");
|
let lines = stdout.split("\n");
|
||||||
// Remove the first line as that is the command that was being run and we
|
// Remove the first line as that is the command that was being run and we
|
||||||
|
|
Loading…
Reference in New Issue