Commit dd5f3bb5 authored by Aaron Harder's avatar Aaron Harder
Browse files

Add some safety checks to "bl module remove"

parent 075a3937
......@@ -21,21 +21,29 @@ module.exports=function(args){
builder.gitStatus(projectId, {commitHash:true}, function(err, state){
var answer;
if(!state[0].clean){
console.log(c.red("\nWARNING: "), c.white("This module has uncommited changes which will be irrevocably lost!"));
if(state && state.length){
if(!state[0].clean){
console.log(c.red("\nWARNING: "), c.white("This module has uncommited changes which will be irrevocably lost!"));
if(!forceDeletion){
answer = readlineSync.question(c.w.yellow("Are you sure you wish to lose the changes in this module? " + c.w.green(projectId) + c.w.grey(" (yes|NO) ")));
if(answer.toLowerCase() !== "yes"){
console.log(c.yellow("\nAnswer was not 'yes' so aborting.\n")); process.exit(0);
}
}
}
if(!forceDeletion){
answer = readlineSync.question(c.w.yellow("Are you sure you wish to lose the changes in this module? " + c.w.green(projectId) + c.w.grey(" (yes|NO) ")));
if(answer.toLowerCase() !== "yes"){
console.log(c.yellow("\nAnswer was not 'yes' so aborting.\n")); process.exit(0);
answer = readlineSync.question(c.w.yellow("\nPlease type the module name to confirm deletion: " + c.w.grey("(" + projectId + ") ") ));
if(answer.toLowerCase() !== projectId){
console.log(c.yellow("\nAnswer did not match module name. Aborting.\n")); process.exit(0);
}
}
}
}else{
console.log(c.red("\nWARNING: "), c.white("This module does not appear to be commited to Git at all.\nAny changes which will be irrevocably lost!"));
if(!forceDeletion){
answer = readlineSync.question(c.w.yellow("\nPlease type the module name to confirm deletion: " + c.w.grey("(" + projectId + ") ") ));
if(answer.toLowerCase() !== projectId){
console.log(c.yellow("\nAnswer did not match module name. Aborting.\n")); process.exit(0);
if(!forceDeletion){
answer = readlineSync.question(c.w.yellow("Are you sure you wish to lose the changes in this module? " + c.w.green(projectId) + c.w.grey(" (yes|NO) ")));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment