UNPKG

plywood-proxy

Version:
22 lines (21 loc) 565 B
'use strict'; var fs = require('fs'); var yaml = require('js-yaml'); function loadFileSync(filepath, postprocess) { if (postprocess === void 0) { postprocess = null; } var fileData = null; try { fileData = fs.readFileSync(filepath, 'utf-8'); if (postprocess === 'json') { fileData = JSON.parse(fileData); } else if (postprocess === 'yaml') { fileData = yaml.safeLoad(fileData); } } catch (e) { return null; } return fileData; } exports.loadFileSync = loadFileSync;