package-json
Advanced tools
Comparing version 2.0.0 to 2.0.1
16
index.js
'use strict'; | ||
var got = require('got'); | ||
var registryUrl = require('registry-url'); | ||
var rc = require('rc'); | ||
module.exports = function (name, version) { | ||
var url = registryUrl(name.split('/')[0]) + | ||
var scope = name.split('/')[0]; | ||
var url = registryUrl(scope) + | ||
encodeURIComponent(name).replace(/^%40/, '@'); | ||
var npmrc = rc('npm'); | ||
var token = npmrc[scope + ':_authToken'] || npmrc['//registry.npmjs.org/:_authToken']; | ||
var headers = {}; | ||
return got(url, {json: true}) | ||
if (token) { | ||
headers.authorization = 'Bearer ' + token; | ||
} | ||
return got(url, { | ||
json: true, | ||
headers: headers | ||
}) | ||
.then(function (res) { | ||
@@ -11,0 +23,0 @@ var data = res.body; |
{ | ||
"name": "package-json", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Get the package.json of a package from the npm registry", | ||
@@ -34,2 +34,3 @@ "license": "MIT", | ||
"got": "^4.2.0", | ||
"rc": "^1.1.2", | ||
"registry-url": "^3.0.3" | ||
@@ -36,0 +37,0 @@ }, |
@@ -41,2 +41,3 @@ # package-json [![Build Status](https://travis-ci.org/sindresorhus/package-json.svg?branch=master)](https://travis-ci.org/sindresorhus/package-json) | ||
- [latest-version](https://github.com/sindresorhus/latest-version) - Get the latest version of a npm package | ||
- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword | ||
@@ -43,0 +44,0 @@ - [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of a npm user |
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
4064
34
50
3
+ Addedrc@^1.1.2