forked from jhipster/generator-jhipster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-base.js
31 lines (27 loc) · 1017 Bytes
/
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
'use strict';
var path = require('path'),
util = require('util'),
yeoman = require('yeoman-generator'),
jhipsterUtils = require('./util.js');
module.exports = Generator;
function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.env.options.appPath = this.config.get('appPath') || 'src/main/webapp';
}
util.inherits(Generator, yeoman.generators.NamedBase);
Generator.prototype.addScriptToIndex = function (script) {
try {
var appPath = this.env.options.appPath;
console.log("appPath: " + this.env.options.appPath);
var fullPath = path.join(appPath, 'index.html');
jhipsterUtils.rewriteFile({
file: fullPath,
needle: '<!-- endbuild -->',
splicable: [
'<script src="scripts/' + script + '"></script>'
]
});
} catch (e) {
console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + script + '.js ' + 'not added.\n'.yellow);
}
};