Skip to content

Commit 73c7517

Browse files
committed
fix --coffee and --minsafe; close yeoman#48
1 parent 9ec90c1 commit 73c7517

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

route/index.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
'use strict';
22
var path = require('path');
33
var util = require('util');
4-
var yeoman = require('yeoman-generator');
4+
var ScriptBase = require('../script-base.js');
55
var angularUtils = require('../util.js');
66

77

88
module.exports = Generator;
99

1010
function Generator() {
11-
yeoman.generators.NamedBase.apply(this, arguments);
12-
this.sourceRoot(path.join(__dirname, '../templates'));
13-
14-
this.hookFor('angular:controller', {
15-
args: [this.name]
16-
});
17-
18-
this.hookFor('angular:view', {
19-
args: [this.name]
20-
});
11+
ScriptBase.apply(this, arguments);
12+
this.hookFor('angular:controller');
13+
this.hookFor('angular:view');
2114
}
22-
23-
util.inherits(Generator, yeoman.generators.NamedBase);
15+
util.inherits(Generator, ScriptBase);
2416

2517
Generator.prototype.rewriteAppJs = function () {
2618
angularUtils.rewriteFile({

script-base.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,33 @@ module.exports = Generator;
99
function Generator() {
1010
yeoman.generators.NamedBase.apply(this, arguments);
1111

12-
this.option('coffee');
12+
if (typeof this.env.options.coffee === 'undefined') {
13+
this.option('coffee');
1314

14-
// attempt to detect if user is using CS or not
15-
// if cml arg provided, use that; else look for the existence of cs
15+
// attempt to detect if user is using CS or not
16+
// if cml arg provided, use that; else look for the existence of cs
17+
if (!this.options.coffee &&
18+
this.expandFiles('/app/scripts/**/*.coffee', {}).length > 0) {
19+
this.options.coffee = true;
20+
}
1621

17-
if (!this.options.coffee &&
18-
this.expandFiles('/app/scripts/**/*.coffee', {}).length > 0) {
19-
this.options.coffee = true;
22+
this.env.options.coffee = this.options.coffee;
23+
}
24+
25+
if (typeof this.env.options.minsafe === 'undefined') {
26+
this.option('minsafe');
27+
this.env.options.minsafe = this.options.minsafe;
2028
}
2129

2230
var sourceRoot = '/templates/javascript';
2331
this.scriptSuffix = '.js';
2432

25-
if (this.options.coffee) {
33+
if (this.env.options.coffee) {
2634
sourceRoot = '/templates/coffeescript';
2735
this.scriptSuffix = '.coffee';
2836
}
2937

30-
if (this.options.minsafe) {
38+
if (this.env.options.minsafe) {
3139
sourceRoot += '-min';
3240
}
3341

0 commit comments

Comments
 (0)