Permalink
Browse files

Added GeneratorUtilities.prototype.isBaseDirExists function.

Prevent compound to not create base directory when it already exists.
  • Loading branch information...
1 parent 831d5ea commit f31d44e4eb96b5b1b9561b539af5cfb69f1f3506 @attomos attomos committed Mar 4, 2014
Showing with 12 additions and 2 deletions.
  1. +3 −1 lib/server/generators/app_generator.js
  2. +9 −1 lib/server/generators/generator_utils.js
@@ -47,7 +47,9 @@ AppGenerator.prototype.perform = function (args) {
if (this.options.appName) {
this.baseDir = path.join(this.baseDir, this.options.appName);
}
-
+ if (this.isBaseDirExists()) {
+ return;
+ }
this.createDirectoryStructure();
this.copyFiles();
};
@@ -425,7 +425,7 @@ GeneratorUtilities.prototype.getDatabaseDependency = function() {
}
};
-GeneratorUtilities.prototype.isEvalAllowed = function () {
+GeneratorUtilities.prototype.isEvalAllowed = function() {
return !('noeval' in this.options);
};
@@ -436,4 +436,12 @@ GeneratorUtilities.prototype.generateSecret = function() {
.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;

0 comments on commit f31d44e

Please sign in to comment.