1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 07:47:07 +01:00

Add support for external options file.

This commit is contained in:
hacksalot
2016-01-04 02:50:00 -05:00
parent c8d4a3deb3
commit f65cf8880e
3 changed files with 63 additions and 9 deletions

View File

@ -0,0 +1,24 @@
/**
Definition of the SafeJsonLoader class.
@module syntax-error-ex.js
@license MIT. See LICENSE.md for details.
*/
(function() {
var FS = require('fs');
module.exports = function loadSafeJson( file ) {
try {
return JSON.parse( FS.readFileSync( file ) );
}
catch(ex) {
loadSafeJson.error = ex;
}
return null;
};
}());

View File

@ -1,6 +1,7 @@
/**
Definition of the SyntaxErrorEx class.
@module syntax-error-ex.js
@license MIT. See LICENSE.md for details.
*/
(function() {
@ -26,7 +27,7 @@ Definition of the SyntaxErrorEx class.
colNum = ex.columnNumber;
}
if( lineNum === null || colNum === null ) {
var JSONLint = require('json-lint');
var JSONLint = require('json-lint'); // TODO: json-lint or is-my-json-valid?
var lint = JSONLint( rawData, { comments: false } );
if( lineNum === null ) lineNum = (lint.error ? lint.line : '???');
if( colNum === null ) colNum = (lint.error ? lint.character : '???');