-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 894 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
37
38
39
const madge = require('madge'),
fs = require('fs-extra');
var args = process.argv.slice(2);
madge(args[0], {
fileExtensions: ['ts']
}).then((res) => {
let tree = res.obj();
let finalData = {
nodes: [],
links: []
};
for (var prop in tree) {
finalData.nodes.push({
id: prop
})
let originalTargets = tree[prop],
i = 0,
len = originalTargets.length;
for (i; i < len; i++) {
finalData.links.push({
source: originalTargets[i],
target: prop
});
}
}
fs.copy('./resources', './dist', err => {
if (err) return console.error(err)
fs.outputJson('dist/data.json', finalData, err => {
if (err) return console.error(err);
console.log('Generation complete !')
});
});
});