autostrip-json-comments
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -9,9 +9,3 @@ var installed = false; | ||
hook.hookJsonRequire(function (text, filename) { | ||
var transformed = strip(text); | ||
console.log(typeof transformed); | ||
return transformed; | ||
}); | ||
console.log('installed json load hook'); | ||
hook.hookJsonRequire(strip); | ||
installed = true; | ||
@@ -18,0 +12,0 @@ } |
{ | ||
"name": "autostrip-json-comments", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Installs nodejs require hook to strip JSON comments", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node ./node_modules/gt test/*.js" | ||
}, | ||
@@ -16,7 +16,28 @@ "keywords": [ | ||
], | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
"pre-commit": ["grunt", "npm test"], | ||
"pre-push": [ | ||
"rm -rf node_modules", | ||
"npm install", | ||
"npm test" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:uTest/autostrip-json-comments.git" | ||
}, | ||
"author": "Gleb Bahmutov <gleb.bahmutov@utest.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"strip-json-comments": "~0.1.1" | ||
}, | ||
"devDependencies": { | ||
"gt": "~0.8.20", | ||
"pre-git": "0.0.13", | ||
"matchdep": "~0.3.0", | ||
"grunt-contrib-jshint": "~0.7.2", | ||
"grunt": "~0.4.1", | ||
"grunt-readme": "~0.3.0", | ||
"time-grunt": "~0.2.1", | ||
"jshint-stylish": "~0.1.3", | ||
"grunt-nice-package": "~0.1.5" | ||
} | ||
} |
@@ -73,3 +73,7 @@ // based on https://github.com/gotwarlost/istanbul/blob/master/lib/hook.js | ||
function unloadRequireCache(matcher) { | ||
function unloadJsonCache() { | ||
function matcher(filename) { | ||
return /\.json$/.test(filename); | ||
} | ||
if (matcher && typeof require !== 'undefined' && require && require.cache) { | ||
@@ -164,4 +168,4 @@ Object.keys(require.cache).forEach(function (filename) { | ||
unhookRunInThisContext : unhookRunInThisContext,*/ | ||
unloadRequireCache: unloadRequireCache | ||
unloadJsonCache: unloadJsonCache | ||
}; | ||
@@ -6,15 +6,17 @@ gt.module('strips comments in require', { | ||
teardownOnce: function () { | ||
require('../src/hook').unhookJsonRequire(); | ||
require('../src/hook').unloadJsonCache(); | ||
} | ||
}); | ||
// installs JSON require hook | ||
// require('../index'); | ||
gt.test('loading json with comments', function () { | ||
gt.test('loading json with comments works', function () { | ||
var json = require('./commented'); | ||
console.log('json returned is', typeof json); | ||
console.log(json); | ||
gt.object(json, 'returns an object'); | ||
gt.ok(json.works, 'loaded commented json'); | ||
}); | ||
gt.test('loading json without comments is ok', function () { | ||
var json = require('../package'); | ||
gt.object(json, 'returns an object'); | ||
gt.string(json.name, 'has name'); | ||
}); |
gt.module('without hook'); | ||
gt.test('loading json without comments', function () { | ||
gt.test('loading json without comments is ok', function () { | ||
var json = require('../package'); | ||
@@ -10,1 +10,7 @@ console.log('json returned is', typeof json); | ||
}); | ||
gt.test('loading commented json raises Exception', function () { | ||
gt.raises(function () { | ||
var json = require('./commented.json'); | ||
}, 'Exception'); | ||
}); |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
17810
17
232
2
1
101
4
9