mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add script to remove a package
This commit is contained in:
30
scripts/not-needed.js
Normal file
30
scripts/not-needed.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// Script to remove a package from DefinitelyTyped and add it to notNeededPackages.json
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const typingsPackageName = process.argv[2];
|
||||
const asOfVersion = process.argv[3];
|
||||
const sourceRepoURL = process.argv[4];
|
||||
const libraryName = process.argv[5] || typingsPackageName;
|
||||
|
||||
if (process.argv.length !== 5 && process.argv.length !== 6) {
|
||||
console.log("Usage: npm run not-needed -- typingsPackageName asOfVersion sourceRepoURL [libraryName]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
rmdirRecursive(typingsPackageName);
|
||||
const notNeededPackages = JSON.parse(fs.readFileSync("notNeededPackages.json", "utf-8"));
|
||||
notNeededPackages.packages.push({ libraryName, typingsPackageName, sourceRepoURL, asOfVersion });
|
||||
fs.writeFileSync("notNeededPackages.json", JSON.stringify(notNeededPackages, undefined, 4), "utf-8");
|
||||
|
||||
function rmdirRecursive(dir) {
|
||||
for (let entry of fs.readdirSync(dir)) {
|
||||
entry = path.join(dir, entry)
|
||||
if (fs.statSync(entry).isDirectory())
|
||||
rmdirRecursive(entry);
|
||||
else
|
||||
fs.unlinkSync(entry);
|
||||
}
|
||||
fs.rmdirSync(dir);
|
||||
}
|
||||
Reference in New Issue
Block a user