-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·43 lines (35 loc) · 1022 Bytes
/
Copy pathindex.js
File metadata and controls
executable file
·43 lines (35 loc) · 1022 Bytes
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
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const async = require('async');
const gexf = require('gexf');
const argv = require('yargs')
.alias('o', 'output')
.alias('p', 'path')
.argv
const DeckReader = require('./lib/DeckReader');
const deckReader = DeckReader();
const GraphBuilder = require('./lib/GraphBuilder');
const cardCounter = 0;
const cards = {};
const decks = [];
if (!argv.path) {
console.log('Must provide path to deck files folder');
process.exit(-1);
}
const path = argv.path;
const output = argv.output || `${__dirname}/output.gexf`;
fs.readdir(path, (err, files) => {
async.forEach(files, (file, nextFile) => {
deckReader.read(`${path}/${file}`, (err, deck) => {
decks.push(deck);
return nextFile();
});
}, (err) => {
const builder = GraphBuilder();
builder.build({ decks, output }, (err, data) => {
if (err) return console.log(`Uh, something went wrong: ${err}`);
return console.log(`Graph successfully generated in: ${output}`);
});
});
});