New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

autostrip-json-comments

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autostrip-json-comments - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

.jshintrc

8

index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc