Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from apigee-127/none-all-option
Browse files Browse the repository at this point in the history
add overwrite this and following
  • Loading branch information
mohsen1 committed Jul 22, 2015
2 parents 06ffb79 + dd30414 commit 5f96830
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/commands/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,28 +455,36 @@ function testGenerate(directory, options, cb) {

var finalResult = template.testGen(result, config);
var existingFiles = fs.readdirSync(path.join(directory, 'test'));
var skipAll = false;

async.filterSeries(finalResult, function(file, cb) {
if (overwriteAll) {
cb(true);
} else if(skipAll){
cb(false);
} else {
if (lodash.includes(existingFiles, file.name)) {
var prompt = util.format('Conflict on %s:', file.name);
var question = {type: 'expand', message: prompt, name: 'overwrite', choices: [
{
key: "y",
name: "Overwrite",
name: "Overwrite this one and show the next",
value: "overwrite"
},
{
key: "a",
name: "Overwrite this one and all next",
name: "Overwrite this one and all of the next",
value: "overwrite_all"
},
{
key: 'n',
name: 'Overwrite none',
value: 'overwrite_none'
name: 'Skip this one and show the next',
value: 'overwrite_skip'
},
{
key: 'x',
name: 'Skip this one and all of the next',
value: 'overwrite_skip_all'
}
]};

Expand All @@ -486,7 +494,10 @@ function testGenerate(directory, options, cb) {
} else if (answers.overwrite === 'overwrite_all') {
overwriteAll = true;
cb(true);
} else if (answers.overwrite === 'overwrite_skip') {
cb(false);
} else {
skipAll = true;
cb(false);
}
});
Expand Down

0 comments on commit 5f96830

Please sign in to comment.