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