-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 969 Bytes
/
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
'use strict';
var path = require('path');
var xFs = require('xcraft-core-fs');
var backendsRoot = path.join(__dirname, 'backends');
var backends = {};
var backendsType = xFs.lsdir(backendsRoot);
backendsType.forEach(function (type) {
const typeRoot = path.join(backendsRoot, type);
var backendsCmd = xFs.ls(typeRoot, /\.js$/);
backends[type] = {};
backendsCmd.forEach(function (cmd) {
var cmdName = cmd.replace(/\.js$/, '');
backends[type][cmdName] = require(path.join(backendsRoot, type, cmd));
});
const backendsSubType = xFs.lsdir(typeRoot);
backendsSubType.forEach((subType) => {
const backendsSubCmd = xFs.ls(path.join(typeRoot, subType), /\.js$/);
backends[type][subType] = {};
backendsSubCmd.forEach((cmd) => {
const cmdName = cmd.replace(/\.js$/, '');
backends[type][subType][cmdName] = require(path.join(
typeRoot,
subType,
cmd
));
});
});
});
module.exports = backends;