forked from Vertafore/docular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (42 loc) · 1.97 KB
/
index.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
var exec = require('child_process').exec;
var gen_docs = require(__dirname + '/lib/scripts/gen-docs.js');
var path = require('path');
var noop = function(){};
module.exports = {
genDocs: function (options, callBack) {
var callBack = callBack || noop;
gen_docs.generate(options, callBack);
},
server: function(port, callBack) {
var callBack = callBack || noop;
//Run the gen-docs script
var serverScript = '../nodeserver/server.js ';
var command_gen_docs = 'node ' + serverScript + port;
//determine the working directory for this command (this script could be being called from grunt plugin)
var workingDirectory = path.relative(process.cwd(), __dirname + '/lib/webapp/');
exec(command_gen_docs, {cwd: workingDirectory}, function(err, stdout, stderr) {
//bubble up errors that may come from this process and call the callback
console.log(stdout);
callBack();
});
},
loadDocAPI: function(docAPI, callBack) {
var callBack = callBack || noop;
var isDocularDocApi = /^docular-doc-api-([^\/\\]+)$/;
//first make sure it is a valid namespaced doc_api
if(isDocularDocApi.test(docAPI)){
//the command to install an npm package
var command_add_api = 'npm install ' + docAPI;
//determine the working directory for this command (this script could be being called from grunt plugin)
var workingDirectory = path.relative(process.cwd(), __dirname);
exec(command_add_api, {cwd: workingDirectory}, function(err, stdout, stderr) {
//bubble up errors that may come from this process and call the callback
console.log(stdout);
callBack();
});
} else {
console.log("WARNING: The docAPI '" + docAPI + "', does not follow the docular-doc-api- namespacing convention.");
callBack();
}
}
};