From e38d4faf9f8a9373a762733e5a93aab36704bfdf Mon Sep 17 00:00:00 2001 From: Charles Crawford Date: Fri, 15 Jun 2018 14:38:02 -0700 Subject: [PATCH] support module interface reading file paths --- lib/jsonlint.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jsonlint.js b/lib/jsonlint.js index 598c18c..de881fb 100644 --- a/lib/jsonlint.js +++ b/lib/jsonlint.js @@ -55,6 +55,9 @@ parseError: function parseError(str, hash) { throw new Error(str); }, parse: function parse(input) { + if (input.length && (input[0] === '.' || input[0] === '/')) { + input = require('fs').readFileSync(input).toString(); + } var self = this, stack = [0], vstack = [null], // semantic value stack @@ -429,4 +432,4 @@ exports.main = function commonjsMain(args) { if (typeof module !== 'undefined' && require.main === module) { exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args); } -} \ No newline at end of file +}