Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added configuration for generating files with 'use strict' #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CUSTOMIZING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Here is an example configuration that matches the default behavior of the subgen
```js
{
"uirouter": false,
"jsstrict": false,
"partialDirectory": "partial/",
"directiveDirectory": "directive/",
"serviceDirectory": "service/",
Expand Down
16 changes: 16 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ CgangularGenerator.prototype.askFor = function askFor() {
}.bind(this));
};

CgangularGenerator.prototype.askForStrict = function askFor() {
var cb = this.async();

var prompts = [{
type: 'confirm',
name: 'jsstrict',
message: 'Would you like your AngularJS code to \'use strict\'?',
default: true
}];

this.prompt(prompts, function (props) {
this.config.set('jsstrict', !!props.jsstrict);
cb();
}.bind(this));
};

CgangularGenerator.prototype.askForUiRouter = function askFor() {
var cb = this.async();

Expand Down
8 changes: 4 additions & 4 deletions app/templates/skeleton/app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
angular.module('<%= _.camelize(appname) %>', ['ui.bootstrap','ui.utils','<%= routerModuleName %>','ngAnimate']);
<% if (!uirouter) { %>
angular.module('<%= _.camelize(appname) %>').config(function($routeProvider) {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
/* Add New Routes Above */
$routeProvider.otherwise({redirectTo:'/home'});

});
<% } %><% if (uirouter) { %>
angular.module('<%= _.camelize(appname) %>').config(function($stateProvider, $urlRouterProvider) {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
/* Add New States Above */
$urlRouterProvider.otherwise('/home');

});
<% } %>
angular.module('<%= _.camelize(appname) %>').run(function($rootScope) {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
$rootScope.safeApply = function(fn) {
var phase = $rootScope.$$phase;
if (phase === '$apply' || phase === '$digest') {
Expand All @@ -27,4 +27,4 @@ angular.module('<%= _.camelize(appname) %>').run(function($rootScope) {
}
};

});
});
1 change: 1 addition & 0 deletions directive/templates/complex/directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular.module('<%= appname %>').directive('<%= _.camelize(name) %>', function() {
<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
return {
restrict: 'E',
replace: true,
Expand Down
1 change: 1 addition & 0 deletions directive/templates/simple/directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular.module('<%= appname %>').directive('<%= _.camelize(name) %>', function() {
<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
return {
restrict: 'A',
link: function(scope, element, attrs, fn) {
Expand Down
1 change: 1 addition & 0 deletions filter/templates/filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular.module('<%= appname %>').filter('<%= _.camelize(name) %>', function() {
<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
return function(input,arg) {
return 'output';
};
Expand Down
2 changes: 1 addition & 1 deletion modal/templates/modal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= appname %>').controller('<%= ctrlname %>',function($scope){

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>

});
4 changes: 2 additions & 2 deletions module/templates/module.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
angular.module('<%= _.camelize(name) %>', ['ui.bootstrap','ui.utils','<%= routerModuleName %>','ngAnimate']);
<% if (!uirouter) { %>
angular.module('<%= _.camelize(name) %>').config(function($routeProvider) {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
/* Add New Routes Above */

});
<% } %><% if (uirouter) { %>
angular.module('<%= _.camelize(name) %>').config(function($stateProvider) {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
/* Add New States Above */

});
Expand Down
2 changes: 1 addition & 1 deletion partial/templates/partial.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= appname %>').controller('<%= ctrlname %>',function($scope){

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>

});
2 changes: 1 addition & 1 deletion service/templates/service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('<%= appname %>').factory('<%= _.camelize(name) %>',function() {

<%= config.get('jsstrict') ? "'use strict';\n" : "" %>
var <%= _.camelize(name) %> = {};

return <%= _.camelize(name) %>;
Expand Down