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 @@ ``` |
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
2
4131
- Removedpify@^3.0.0
- Removedpify@3.0.0(transitive)