forked from cliftonc/calipso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.js
40 lines (30 loc) · 762 Bytes
/
help.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
var ejs = require('ejs')
, fs = require('fs');
/**
* Help file
*/
exports.execute = function (params, appPath) {
if (params.length == 0) {
var str = fs.readFileSync(__dirname + '/templates/help.ejs', 'utf8');
} else {
var str = fs.readFileSync(__dirname + '/templates/' + params[0] + '.help.ejs', 'utf8');
}
var scripts = [];
fs.readdir(__dirname + '/', function (err, files) {
if (err) {
console.log(err);
}
files.forEach(function (file) {
if (file.replace('.js', '') != file) {
scripts.push(file.replace('.js', ''));
}
});
var ret = ejs.render(str, {
locals:{
params:params,
scripts:scripts
}, open:"<?", close:"?>"
});
console.log(ret);
});
};