-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatsplitter.js
72 lines (69 loc) · 1.73 KB
/
statsplitter.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
62
63
64
65
66
67
68
69
70
71
72
var fs = require('fs');
var path = require('path');
function getFilePath(dir, base, ext) {
return path.resolve(dir, base + (ext || ''));
}
var fname = process.argv[2];
var fext = path.extname(fname);
var fbase = path.basename(fname, fext);
var fdir = path.dirname(path.resolve(process.cwd(), fname));
var fpath = getFilePath(fdir, fbase, fext);
fs.readFile(fpath, {encoding: 'utf8'}, function(err, data) {
if (err) throw err;
data = JSON.parse(data);
fs.writeFile(
getFilePath(fdir, fbase+'-xml', fext),
JSON.stringify(data.xml, null, '\t'),
function(err) {
if (err) {
console.error('Erro salvando xml', err);
} else {
console.error('xml salvo com sucesso');
}
}
);
fs.writeFile(
getFilePath(fdir, fbase+'-bzip', fext),
JSON.stringify(data.bzip, null, '\t'),
function(err) {
if (err) {
console.error('Erro salvando bzip', err);
} else {
console.error('bzip salvo com sucesso');
}
}
);
fs.writeFile(
getFilePath(fdir, fbase+'-fopt', fext),
JSON.stringify(data.fopt, null, '\t'),
function(err) {
if (err) {
console.error('Erro salvando fopt', err);
} else {
console.error('fopt salvo com sucesso');
}
}
);
fs.writeFile(
getFilePath(fdir, fbase+'-runs', fext),
JSON.stringify(data.runs, null, '\t'),
function(err) {
if (err) {
console.error('Erro salvando runs', err);
} else {
console.error('runs salvo com sucesso');
}
}
);
fs.writeFile(
getFilePath(fdir, fbase+'-current', fext),
JSON.stringify(data.current, null, '\t'),
function(err) {
if (err) {
console.error('Erro salvando current', err);
} else {
console.error('current salvo com sucesso');
}
}
);
});