parent-package-json
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -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'); |
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
7592
82