Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-pkg

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-pkg - npm Package Compare versions

Comparing version 4.0.1 to 5.0.0

33

index.js
'use strict';
const {promisify} = require('util');
const fs = require('fs');
const path = require('path');
const parseJson = require('parse-json');
const pify = require('pify');
const readFileAsync = pify(fs.readFile);
const readFileAsync = promisify(fs.readFile);
module.exports = options => {
options = Object.assign({
module.exports = async options => {
options = {
cwd: process.cwd(),
normalize: true
}, options);
normalize: true,
...options
};
const filePath = path.resolve(options.cwd, 'package.json');
const json = parseJson(await readFileAsync(filePath, 'utf8'));
return readFileAsync(filePath, 'utf8').then(file => {
const json = parseJson(file);
if (options.normalize) {
require('normalize-package-data')(json);
}
if (options.normalize) {
require('normalize-package-data')(json);
}
return json;
});
return json;
};
module.exports.sync = options => {
options = Object.assign({
options = {
cwd: process.cwd(),
normalize: true
}, options);
normalize: true,
...options
};

@@ -34,0 +33,0 @@ const filePath = path.resolve(options.cwd, 'package.json');

{
"name": "read-pkg",
"version": "4.0.1",
"description": "Read a package.json file",
"license": "MIT",
"repository": "sindresorhus/read-pkg",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"json",
"read",
"parse",
"file",
"fs",
"graceful",
"load",
"pkg",
"package",
"normalize"
],
"dependencies": {
"normalize-package-data": "^2.3.2",
"parse-json": "^4.0.0",
"pify": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "read-pkg",
"version": "5.0.0",
"description": "Read a package.json file",
"license": "MIT",
"repository": "sindresorhus/read-pkg",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"json",
"read",
"parse",
"file",
"fs",
"graceful",
"load",
"pkg",
"package",
"normalize"
],
"dependencies": {
"normalize-package-data": "^2.3.2",
"parse-json": "^4.0.0"
},
"devDependencies": {
"ava": "^1.3.1",
"xo": "^0.24.0"
},
"xo": {
"ignores": [
"test/test.js"
]
}
}

@@ -27,6 +27,6 @@ # read-pkg [![Build Status](https://travis-ci.org/sindresorhus/read-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg)

console.log(await readPkg());
//=> {name: 'read-pkg', ...}
//=> {name: 'read-pkg', …}
console.log(await readPkg({cwd: 'some-other-directory'});
//=> {name: 'unicorn', ...}
//=> {name: 'unicorn', …}
})();

@@ -33,0 +33,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