Skip to content

Commit

Permalink
Added GeneratorUtilities.prototype.isBaseDirExists function.
Browse files Browse the repository at this point in the history
Prevent compound to not create base directory when it already exists.
  • Loading branch information
attomos committed Mar 4, 2014
1 parent 831d5ea commit f31d44e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/server/generators/app_generator.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ AppGenerator.prototype.perform = function (args) {
if (this.options.appName) { if (this.options.appName) {
this.baseDir = path.join(this.baseDir, this.options.appName); this.baseDir = path.join(this.baseDir, this.options.appName);
} }

if (this.isBaseDirExists()) {
return;
}
this.createDirectoryStructure(); this.createDirectoryStructure();
this.copyFiles(); this.copyFiles();
}; };
Expand Down
10 changes: 9 additions & 1 deletion lib/server/generators/generator_utils.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ GeneratorUtilities.prototype.getDatabaseDependency = function() {
} }
}; };


GeneratorUtilities.prototype.isEvalAllowed = function () { GeneratorUtilities.prototype.isEvalAllowed = function() {
return !('noeval' in this.options); return !('noeval' in this.options);
}; };


Expand All @@ -436,4 +436,12 @@ GeneratorUtilities.prototype.generateSecret = function() {
.digest('hex'); .digest('hex');
}; };


GeneratorUtilities.prototype.isBaseDirExists = function() {
var exists = fs.existsSync(this.baseDir);
if (exists) {
this.log($('"' + this.baseDir + '" exists', this.baseDir).bold.red);
}
return exists;
};

module.exports = GeneratorUtilities; module.exports = GeneratorUtilities;

0 comments on commit f31d44e

Please sign in to comment.