123456789101112131415161718192021 |
- const _fs = require('fs-magic');
- // parse json file and allow single line comments
- async function readJSONFile(filename){
- // load file
- let raw = await _fs.readFile(filename, 'utf8');
- // strip single line js comments
- raw = raw.replace(/^\s*\/\/.*$/gm, '');
- // parse text
- try {
- return JSON.parse(raw);
- } catch(e) {
- console.log("Error parsing JSON file: "+filename+"\n");
- throw e;
- }
- //return JSON.parse(raw);
- }
- module.exports = readJSONFile;
|