-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJakefile.js
40 lines (32 loc) · 1.43 KB
/
Jakefile.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
desc('Adds the plugin and template into the JSDoc3 installation.');
task('install', function (jsdocHome) {
var fs = require('fs'),
util = require('util'),
path = require('path'),
wrench = require('wrench/wrench'),
jsdoc = jsdocHome || process.env.JSDOC_HOME,
config, readme;
//If no location, display error and exit
if (!jsdoc) {
fail("No JSDoc home specified.");
}
if (!path.existsSync(jsdoc)) {
fail("JSDoc home [" + jsdoc + "] is not valid.");
}
//TODO: Test jsdoc is actually present at location?
//Otherwise, copy over the files
//First the plugin
wrench.copyDirSyncRecursive('plugins', path.join(jsdoc, "plugins"), {preserve: true});
//Then the template
wrench.copyDirSyncRecursive('templates', path.join(jsdoc, "templates"), {preserve: true});
//Also throw in the README so it can be easily accessed
readme = fs.readFileSync('README.md', 'utf8');
fs.writeFileSync(path.join(jsdoc, 'templates', 'jui', 'README.md'), readme, 'utf8');
//And finally edit the conf.json
config = JSON.parse(fs.readFileSync(path.join(jsdoc, 'conf.json'), 'utf8'));
if (config.plugins.indexOf('plugins/jquery-ui-widget') == -1) {
config.plugins.push('plugins/jquery-ui-widget');
fs.writeFileSync(path.join(jsdoc, 'conf.json'), JSON.stringify(config, null, " "), 'utf8');
}
process.exit(0);
});