2013-02-26 11:44:22 +00:00
|
|
|
/*
|
2019-02-08 22:20:57 +00:00
|
|
|
* A tool for deleting pads from the CLI, because sometimes a brick is required
|
|
|
|
* to fix a window.
|
|
|
|
*/
|
2013-02-26 11:44:22 +00:00
|
|
|
|
2019-02-08 22:20:57 +00:00
|
|
|
if (process.argv.length != 3) {
|
2013-02-26 11:44:22 +00:00
|
|
|
console.error("Use: node deletePad.js $PADID");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2019-02-08 22:20:57 +00:00
|
|
|
|
|
|
|
// get the padID
|
2019-01-26 23:52:02 +00:00
|
|
|
let padId = process.argv[2];
|
2019-02-08 22:20:57 +00:00
|
|
|
|
2019-01-26 23:52:02 +00:00
|
|
|
let npm = require('../src/node_modules/npm');
|
2019-02-08 22:20:57 +00:00
|
|
|
|
2019-01-26 23:52:02 +00:00
|
|
|
npm.load({}, async function(er) {
|
|
|
|
if (er) {
|
|
|
|
console.error("Could not load NPM: " + er)
|
|
|
|
process.exit(1);
|
2013-02-26 11:44:22 +00:00
|
|
|
}
|
2019-01-26 23:52:02 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
let settings = require('../src/node/utils/Settings');
|
|
|
|
let db = require('../src/node/db/DB');
|
|
|
|
await db.init();
|
|
|
|
|
|
|
|
padManager = require('../src/node/db/PadManager');
|
|
|
|
await padManager.removePad(padId);
|
|
|
|
|
2019-02-08 22:20:57 +00:00
|
|
|
console.log("Finished deleting padId: " + padId);
|
2019-01-26 23:52:02 +00:00
|
|
|
process.exit(0);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
if (err.name === "apierror") {
|
|
|
|
console.error(e);
|
|
|
|
} else {
|
|
|
|
console.trace(e);
|
|
|
|
}
|
|
|
|
process.exit(1);
|
2013-02-26 11:44:22 +00:00
|
|
|
}
|
|
|
|
});
|