Skip to content

Commit

Permalink
fix(generator): add app modules dependency to app
Browse files Browse the repository at this point in the history
Add AngularJS app dependencies to the list based on prompt answers

Fixes #230
  • Loading branch information
eddiemonge authored and passy committed Sep 22, 2013
1 parent c514aeb commit a45b71c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
17 changes: 17 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ Generator.prototype.askForModules = function askForModules() {
this.cookiesModule = hasMod('cookiesModule');
this.sanitizeModule = hasMod('sanitizeModule');

var angMods = [];

if (this.cookiesModule) {
angMods.push("'ngCookies'");
}

if (this.resourceModule) {
angMods.push("'ngResource'");
}
if (this.sanitizeModule) {
angMods.push("'ngSanitize'");
}

if (angMods.length) {
this.env.options.angularDeps = "\n " + angMods.join(",\n ") +"\n";
}

cb();
}.bind(this));
};
Expand Down
1 change: 1 addition & 0 deletions main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ var Generator = module.exports = function Generator() {
util.inherits(Generator, ScriptBase);

Generator.prototype.createAppFile = function createAppFile() {
this.angularModules = this.env.options.angularDeps;
this.appTemplate('app', 'scripts/app');
};
2 changes: 1 addition & 1 deletion templates/coffeescript-min/app.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

angular.module('<%= _.camelize(appname) %>App', [])
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
.config ['$routeProvider', ($routeProvider) ->
$routeProvider
.when '/',
Expand Down
2 changes: 1 addition & 1 deletion templates/coffeescript/app.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

angular.module('<%= _.camelize(appname) %>App', [])
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
.config ($routeProvider) ->
$routeProvider
.when '/',
Expand Down
2 changes: 1 addition & 1 deletion templates/javascript-min/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

angular.module('<%= _.camelize(appname) %>App', [])
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
Expand Down
2 changes: 1 addition & 1 deletion templates/javascript/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

angular.module('<%= _.camelize(appname) %>App', [])
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
Expand Down

0 comments on commit a45b71c

Please sign in to comment.