Skip to content

Commit a45b71c

Browse files
eddiemongepassy
authored andcommitted
fix(generator): add app modules dependency to app
Add AngularJS app dependencies to the list based on prompt answers Fixes #230
1 parent c514aeb commit a45b71c

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

app/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ Generator.prototype.askForModules = function askForModules() {
124124
this.cookiesModule = hasMod('cookiesModule');
125125
this.sanitizeModule = hasMod('sanitizeModule');
126126

127+
var angMods = [];
128+
129+
if (this.cookiesModule) {
130+
angMods.push("'ngCookies'");
131+
}
132+
133+
if (this.resourceModule) {
134+
angMods.push("'ngResource'");
135+
}
136+
if (this.sanitizeModule) {
137+
angMods.push("'ngSanitize'");
138+
}
139+
140+
if (angMods.length) {
141+
this.env.options.angularDeps = "\n " + angMods.join(",\n ") +"\n";
142+
}
143+
127144
cb();
128145
}.bind(this));
129146
};

main/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ var Generator = module.exports = function Generator() {
1212
util.inherits(Generator, ScriptBase);
1313

1414
Generator.prototype.createAppFile = function createAppFile() {
15+
this.angularModules = this.env.options.angularDeps;
1516
this.appTemplate('app', 'scripts/app');
1617
};

templates/coffeescript-min/app.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
angular.module('<%= _.camelize(appname) %>App', [])
3+
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
44
.config ['$routeProvider', ($routeProvider) ->
55
$routeProvider
66
.when '/',

templates/coffeescript/app.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
angular.module('<%= _.camelize(appname) %>App', [])
3+
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
44
.config ($routeProvider) ->
55
$routeProvider
66
.when '/',

templates/javascript-min/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('<%= _.camelize(appname) %>App', [])
3+
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
44
.config(['$routeProvider', function ($routeProvider) {
55
$routeProvider
66
.when('/', {

templates/javascript/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('<%= _.camelize(appname) %>App', [])
3+
angular.module('<%= _.camelize(appname) %>App', [<%= angularModules %>])
44
.config(function ($routeProvider) {
55
$routeProvider
66
.when('/', {

0 commit comments

Comments
 (0)