-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript-base.js
89 lines (72 loc) · 2.44 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var jarvisUtils = require('./util.js');
module.exports = JarvisGenerator;
function JarvisGenerator() {
yeoman.generators.Base.apply(this, arguments);
try {
this.appname = require(path.join(process.cwd(), 'bower.json')).name;
} catch (e) {
this.appname = path.basename(process.cwd());
}
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, sourceRoot));
}
util.inherits(JarvisGenerator, yeoman.generators.Base);
// JarvisGenerator.prototype.appTemplate = function (src, dest) {
// yeoman.generators.Base.prototype.template.apply(this, [
// src + this.scriptSuffix,
// path.join(this.env.options.appPath, dest) + this.scriptSuffix
// ]);
// };
// JarvisGenerator.prototype.testTemplate = function (src, dest) {
// yeoman.generators.Base.prototype.template.apply(this, [
// src + this.scriptSuffix,
// path.join(this.env.options.testPath, dest) + this.scriptSuffix
// ]);
// };
// JarvisGenerator.prototype.htmlTemplate = function (src, dest) {
// yeoman.generators.Base.prototype.template.apply(this, [
// src,
// path.join(this.env.options.appPath, dest)
// ]);
// };
JarvisGenerator.prototype.addScriptToJade = function (scriptPath, jadeFile, target) {
try {
// console.log(appPath);
jarvisUtils.rewriteFile({
file: jadeFile,
needle: '//' + target,
splicable: [
'script(type="text/javascript", src="' + scriptPath + '")'
]
});
} catch (e) {
console.log('\nUnable to find '.yellow + jadeFile + '. Reference to '.yellow + scriptPath + ' ' + 'not added.\n'.yellow);
}
};
JarvisGenerator.prototype.addToJade = function (text, jadeFile, target) {
try {
// console.log(appPath);
jarvisUtils.rewriteFile({
file: jadeFile,
needle: '//' + target,
splicable: [
'//' + text
]
});
} catch (e) {
console.log('\nUnable to find '.yellow + jadeFile + '. Reference to '.yellow + scriptPath + ' ' + 'not added.\n'.yellow);
}
};
JarvisGenerator.prototype.updateAppJson = function(clientOrServer,section,whatToPush){
var appJson = fs.readFileSync('app.json', 'utf8');
console.log(appJson);
}