forked from DaftMonk/generator-ng-component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-base.js
More file actions
51 lines (41 loc) · 1.57 KB
/
script-base.js
File metadata and controls
51 lines (41 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
var util = require('util');
var path = require('path');
var lodash = require('lodash');
var s = require('underscore.string');
var yeoman = require('yeoman-generator');
var ngUtils = require('./util.js');
// extend lodash with underscore.string
lodash.mixin(s.exports());
var Generator = module.exports = function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.lodash = lodash;
try {
this.appname = require(path.join(process.cwd(), 'bower.json')).name;
} catch (e) {
this.appname = path.basename(process.cwd());
}
this.appname = lodash.slugify(lodash.humanize(this.appname));
this.scriptAppName = this.config.get('moduleName') || lodash.camelize(this.appname) + ngUtils.appName(this);
this.cameledName = lodash.camelize(this.name);
this.classedName = lodash.classify(this.name);
this.kebabName = lodash.kebabCase(this.name);
this.hasFilter = function(filter) {
return this.config.get('filters').indexOf(filter) !== -1;
}.bind(this);
// dynamic assertion statements
this.expect = function() {
return this.hasFilter('expect') ? 'expect(' : '';
}.bind(this);
this.to = function() {
return this.hasFilter('expect') ? ').to' : '.should';
}.bind(this);
if (typeof this.env.options.appPath === 'undefined') {
try {
this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath;
} catch (e) {}
this.env.options.appPath = this.env.options.appPath || 'app';
}
this.sourceRoot(path.join(__dirname, '/templates'));
};
util.inherits(Generator, yeoman.generators.NamedBase);