-
Notifications
You must be signed in to change notification settings - Fork 5
/
dist.js
41 lines (33 loc) · 857 Bytes
/
dist.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
'use strict';
var fs = require('fs'),
globby = require('globby'),
Q = require('q');
var SRC_PATH = './data/*.json',
DEST_PATH = './dist/nfcList';
var nfcList = [];
function readJson(path) {
return Q.nfcall(fs.readFile, path, 'utf-8').then(function (json) {
json = JSON.parse(json);
nfcList = nfcList.concat(json);
});
}
function writeJson() {
fs.writeFile(DEST_PATH + '.json', JSON.stringify(nfcList, null, 4), function(err) {
if(err) {
console.log(err);
} else {
console.log('JSON saved to ' + DEST_PATH + '.json');
}
});
fs.writeFile(DEST_PATH + '.min.json', JSON.stringify(nfcList), function(err) {
if(err) {
console.log(err);
} else {
console.log('JSON saved to ' + DEST_PATH + '.min.json');
}
});
}
var promise = Q.nfcall(globby, SRC_PATH)
.invoke('map', readJson).all()
.then(writeJson);
promise.done();