require-json5
Advanced tools
Comparing version 1.0.2 to 1.1.0
15
index.js
@@ -5,7 +5,7 @@ /** | ||
* @license MIT | ||
* @version 1.0.2 | ||
* @version 1.1.0 | ||
* @author Dumitru Uzun (DUzun.Me) | ||
*/ | ||
var VERSION = '1.0.2'; | ||
var VERSION = '1.1.0'; | ||
@@ -19,3 +19,12 @@ var fs = require('fs'); | ||
function requireJSON5(filename) { | ||
if ( path.extname(filename) == '' ) filename += fs.existsSync(filename + '.json5') ? '.json5' : '.json'; | ||
if ( path.extname(filename) == '' ) { | ||
const extensions = ['.json5', '.json']; | ||
for(var i=0, l = extensions.length, ext; i<l; ++i) { | ||
ext = extensions[i]; | ||
if(fs.existsSync(filename + ext)) { | ||
filename += ext; | ||
break; | ||
} | ||
} | ||
} | ||
try { | ||
@@ -22,0 +31,0 @@ return JSON5.parse(stripBOM(fs.readFileSync(filename, 'utf8'))); |
{ | ||
"name": "require-json5", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Require JSON5 files in node - a better JSON for ES5 era", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"test": "node test/", | ||
"verup": "verup" | ||
"verup": "npx verup" | ||
}, | ||
@@ -15,2 +15,3 @@ "repository": { | ||
}, | ||
"reveal": true, | ||
"keywords": [ | ||
@@ -34,3 +35,3 @@ "environment", | ||
], | ||
"author": "Dumitru Uzun <contanct@duzun.me> (https://DUzun.Me)", | ||
"author": "Dumitru Uzun <contact@duzun.me> (https://DUzun.Me)", | ||
"license": "MIT", | ||
@@ -42,3 +43,3 @@ "bugs": { | ||
"dependencies": { | ||
"json5": "^x.x" | ||
"json5": "^2.x" | ||
}, | ||
@@ -45,0 +46,0 @@ "devDependencies": { |
@@ -19,5 +19,9 @@ | ||
// 3. | ||
var config = requireJSON(__dirname + '/.configrc'); // no extension file | ||
asert.equal(config.noext, true); | ||
requireJSON.replace(); | ||
// 3. | ||
// 4. | ||
var config = require("./config"); // .json file | ||
@@ -28,3 +32,3 @@ asert.equal(config.name, 'json', 'yes'); | ||
// 4. | ||
// 5. | ||
var configStr = fs.readFileSync(__dirname + "/config5.json5", 'utf8'); | ||
@@ -31,0 +35,0 @@ var config = requireJSON.parse(configStr); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
8495
97
0
Updatedjson5@^2.x