mirror of
https://github.com/vector-im/element-web.git
synced 2024-09-09 22:55:12 +00:00
Improve dead code detection (#22829)
This commit is contained in:
parent
b3b8e2e0a2
commit
ee3b9c3310
1 changed files with 7 additions and 1 deletions
|
@ -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 a new issue