forked from zakilo/generator-admix-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script-base.js
executable file
·58 lines (45 loc) · 1.66 KB
/
script-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
56
57
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var utils = require('./util.js');
var chalk = require('chalk');
var Generator = module.exports = function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.appname = path.basename(process.cwd());
this.scriptAppName = this._.camelize(this.appname) + utils.appName(this);
this.name = this.name.replace('.html', '');
this.cameledName = this._.camelize(this.name);
this.classedName = this._.classify(this.name);
//增加对创建组件,actions,store的支持
var compPath = (this.name).split(':');
if(compPath.length == 2){
this.compName = this._.classify(compPath[1]);
}
if (typeof this.env.options.appPath === 'undefined') {
this.env.options.appPath = this.options.appPath;
if (!this.env.options.appPath) {
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.options.appPath = this.env.options.appPath;
}
var sourceRoot = '/templates/javascript';
this.scriptSuffix = '.js';
this.sourceRoot(path.join(__dirname, sourceRoot));
};
util.inherits(Generator, yeoman.generators.NamedBase);
Generator.prototype.appTemplate = function (src, dest) {
yeoman.generators.Base.prototype.template.apply(this, [
src,
path.join(this.env.options.appPath, dest.toLowerCase())
]);
};
Generator.prototype.htmlTemplate = function (src, dest) {
yeoman.generators.Base.prototype.template.apply(this, [
src,
path.join('./htmls', dest.toLowerCase())
]);
};