-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.js
34 lines (28 loc) · 974 Bytes
/
parser.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
"use strict";
const fs = require("fs");
const glob = require("glob");
const pino = require("pino");
const { exit } = require("process");
const logger = pino({
prettyPrint: true
});
module.exports = {
parse: function(buildDirectory, ignoreFiles) {
logger.info("Parsing %s", buildDirectory);
logger.info("Ignoring %s", ignoreFiles);
const contracts = [];
// No longer necessary since we are ignoring files by adding a property to 'contract' object.
// const options = ignoreFiles ? {
// ignore: ignoreFiles
// } : {}
const files = glob.sync(buildDirectory + "/**/*.json");//, options);
for (let i = 0; i < files.length; i++) {
const data = fs.readFileSync(files[i]);
var contract = JSON.parse(data);
// Ignore the file if it is in the array of ignore pattern
contract.ignore = ignoreFiles.filter(f => files[i].indexOf(f) > 0).length > 0;
contracts.push(contract);
}
return contracts;
}
};