budibase/scripts/depcheck.js

30 lines
668 B
JavaScript
Raw Normal View History

2024-11-19 18:17:15 +01:00
#!/usr/bin/node
const depcheck = require("depcheck")
function filterResults(missing) {
if (missing.src) {
delete missing.src
}
return missing
}
function printMissing(missing) {
for (let [key, value] of Object.entries(filterResults(missing))) {
console.log(`Package ${key} missing in: ${value.join(", ")}`)
}
}
depcheck(process.cwd(), {
ignorePatterns: ["dist"],
skipMissing: false,
}).then(results => {
if (Object.values(filterResults(results.missing)).length > 0) {
printMissing(results.missing)
console.error("Missing packages found - stopping.")
process.exit(-1)
} else {
console.log("No missing dependencies.")
}
})