Skip to content

Commit

Permalink
Fix for prompt modulePath validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmbrennan committed Feb 4, 2015
1 parent 3739456 commit 33e7fed
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions remove/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,20 @@ module.exports = yeoman.generators.NamedBase.extend({
this.projectName = pkg.name;
},

_moduleExists: function (rootPath) {
var done = this.async();
done(true);
//done(fs.existsSync(this._buildModulePath(rootPath)));
},

_buildModulePath: function (rootPath) {
rootPath = rootPath || 'app';
return path.join(this.env.cwd, 'src', rootPath, this.name);
},

askFor: function () {
var done = this.async();

var moduleExists = function (rootPath) {
return fs.existsSync(this._buildModulePath(rootPath));
}.bind(this);

var prompts = [
{
name: 'modulePath',
message: 'Where is the location of this module?',
default: 'app',
when: !this._moduleExists,
validate: this._moduleExists
when: !moduleExists,
validate: moduleExists
}, {
name: 'remove',
message: 'Are you sure you want to remove ' + this.name + '?',
Expand All @@ -53,6 +46,11 @@ module.exports = yeoman.generators.NamedBase.extend({
this._updateAppJs(this.name);
},

_buildModulePath: function (rootPath) {
rootPath = rootPath || 'app';
return path.join(this.env.cwd, 'src', rootPath, this.name);
},

_updateAppJs: function (camelModuleName) {
var filePath = path.join(this.env.cwd, 'src', 'app', 'app.js');
var file = this.readFileAsString(filePath);
Expand Down

0 comments on commit 33e7fed

Please sign in to comment.