Skip to content

Commit ffa67c5

Browse files
author
Jacob Shufro
committed
Require user confirmation before running morgue nuke, unless -f is passed
1 parent ce0d8d1 commit ffa67c5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

bin/morgue.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const fs = require('fs');
2020
const mkdirp = require('mkdirp');
2121
const promptLib = require('prompt');
2222
const path = require('path');
23+
const readline = require('readline');
2324
const table = require('table').table;
2425
const bt = require('backtrace-node');
2526
const spawn = require('child_process').spawn;
@@ -5010,7 +5011,7 @@ function coronerFlamegraph(argv, config) {
50105011
});
50115012
}
50125013

5013-
function coronerNuke(argv, config) {
5014+
async function coronerNuke(argv, config) {
50145015
abortIfNotLoggedIn(config);
50155016

50165017
var coroner = coronerClientArgv(config, argv);
@@ -5067,6 +5068,24 @@ function coronerNuke(argv, config) {
50675068
errx('No such object.');
50685069
}
50695070

5071+
if (!argv["-f"]) {
5072+
const name = target.get('name');
5073+
const rl = readline.createInterface({
5074+
input: process.stdin,
5075+
output: process.stdout,
5076+
terminal: true
5077+
});
5078+
await new Promise(done => {
5079+
rl.question("You are about to nuke " + name + ". Please type '" + name +"' to confirm: ", confirmation => {
5080+
if (confirmation != name) {
5081+
errx('Confirmation invalid: ' + confirmation);
5082+
}
5083+
done();
5084+
rl.close();
5085+
});
5086+
});
5087+
}
5088+
50705089
bpg.delete(target, { cascade: true });
50715090

50725091
try {

0 commit comments

Comments
 (0)