Skip to content

Commit

Permalink
[wip] Added confirmatino prompt to deactivate #7
Browse files Browse the repository at this point in the history
  • Loading branch information
sthzg committed Aug 6, 2016
1 parent f0ef74e commit 69a867c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions utils/tasks.js
Expand Up @@ -162,8 +162,33 @@ function activateSubgen(generator) {
*/
function deactivateSubgen(generator) {
if (fs.existsSync(generator.subgenDest)) {
fs.unlinkSync(generator.subgenDest);
generator.genData.deactivation = utils.buildSuccess({});
var done = generator.async();

const run = (shouldProceed) => {

if (!shouldProceed) {
generator.env.error('Operation cancelled by user.');
done();
}

fs.unlinkSync(generator.subgenDest);
generator.genData.deactivation = utils.buildSuccess({});

done();
};

if (utils.shouldAutoConfirmYesnos(generator.options.yes)) {
run(true);
} else {
generator.prompt({
type: 'confirm',
name: 'proceed',
message: `I will remove this symlink\n=> ${generator.subgenDest}\nConfirm to proceed:`
})
.then(
answers => run(answers.proceed)
);
}
} else {
const err = `Subgen with name "${generator.subgenName}" doesn't seem to be activated. This is a NOOP.`;
generator.genData.deactivation = utils.buildError(err);
Expand Down

0 comments on commit 69a867c

Please sign in to comment.