mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-10-30 12:47:26 +00:00 
			
		
		
		
	Add support for external options file.
This commit is contained in:
		
							
								
								
									
										24
									
								
								src/utils/safe-json-loader.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/utils/safe-json-loader.js
									
									
									
									
									
										Normal 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; | ||||
|   }; | ||||
|  | ||||
|  | ||||
| }()); | ||||
| @@ -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 : '???'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user