Socket
Socket
Sign inDemoInstall

parent-package-json

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parent-package-json - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

6

lib/index.js

@@ -24,8 +24,8 @@ var fs = require('fs'),

read: function() {
return fs.readFileSync(searchPath + '/package.json', 'utf8');
return fs.readFileSync(path.join(searchPath + '/package.json'), 'utf8');
},
parse: function() {
return JSON.parse(fs.readFileSync(searchPath + '/package.json', 'utf8'));
return JSON.parse(fs.readFileSync(path.join(searchPath + '/package.json'), 'utf8'));
},
path: searchPath + '/package.json'
path: path.join(searchPath + '/package.json')
};

@@ -32,0 +32,0 @@ } else {

{
"name": "parent-package-json",
"version": "1.0.2",
"version": "1.0.3",
"description": "Find, read and parse the package.json of the parent module",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -5,2 +5,3 @@ var assert = require('assert'),

fs = require('fs'),
path = require('path'),
expect = require('chai').expect;

@@ -28,9 +29,9 @@

it('should find a package.json in the parent directory', function() {
expect(parent('test/first_folder/second_folderthird_folder').path).to.equal('test/first_folder/package.json');
expect(parent('test/first_folder/second_folderthird_folder').path).to.equal(path.normalize('test/first_folder/package.json'));
});
it('should find the parent package.json and ignore its own', function() {
expect(parent('test/first_folder/second_folder/third_folder/fourth_folder').path).to.equal('test/first_folder/second_folder/third_folder/package.json');
expect(parent('test/first_folder/second_folder/third_folder/fourth_folder').path).to.equal(path.normalize('test/first_folder/second_folder/third_folder/package.json'));
});
it('should continue until a package.json is found', function() {
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal('test/first_folder/package.json');
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal(path.normalize('test/first_folder/package.json'));
});

@@ -44,3 +45,3 @@ it('should equal to false if no package.json can be found', function() {

it('should be able to read a package.json', function() {
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal('test/first_folder/package.json');
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal(path.normalize('test/first_folder/package.json'));
expect(parent('test/first_folder/second_folder/third_folder').read()).to.equal('{"version":"2.0.0"}');

@@ -52,3 +53,3 @@ });

it('should be able to read and parse a package.json', function() {
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal('test/first_folder/package.json');
expect(parent('test/first_folder/second_folder/third_folder').path).to.equal(path.normalize('test/first_folder/package.json'));
expect(parent('test/first_folder/second_folder/third_folder').parse()).to.eql({'version': '2.0.0'});

@@ -55,0 +56,0 @@ expect(parent('test/first_folder/second_folder/third_folder').parse().version).to.equal('2.0.0');

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