forked from angular-fullstack/generator-angular-fullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator-base.js
55 lines (42 loc) · 1.41 KB
/
generator-base.js
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
52
53
54
55
'use strict';
import util from 'util';
import path from 'path';
import lodash from 'lodash';
import s from 'underscore.string';
import yoWelcome from 'yeoman-welcome';
import * as genUtils from './util';
// extend lodash with underscore.string
lodash.mixin(s.exports());
export function genBase(self) {
self = self || this;
self.lodash = lodash;
self.yoWelcome = yoWelcome;
self.appname = lodash.camelize(lodash.slugify(
lodash.humanize(self.determineAppname())
));
self.scriptAppName = self.appname + genUtils.appSuffix(self);
self.filters = self.filters || self.config.get('filters');
// dynamic assertion statements
self.expect = function() {
return self.filters.expect ? 'expect(' : '';
};
self.to = function() {
return self.filters.expect ? ').to' : '.should';
};
// dynamic relative require path
self.relativeRequire = genUtils.relativeRequire.bind(self);
// process template directory
self.processDirectory = genUtils.processDirectory.bind(self);
// rewrite a file in place
self.rewriteFile = genUtils.rewriteFile;
}
export function genNamedBase(self) {
self = self || this;
// extend genBase
genBase(self);
var name = self.name.replace(/\//g, '-');
self.cameledName = lodash.camelize(name);
self.classedName = lodash.classify(name);
self.basename = path.basename(self.name);
self.dirname = (self.name.indexOf('/') >= 0) ? path.dirname(self.name) : self.name;
}