Comparing version 2.4.0 to 3.0.0
42
index.js
'use strict'; | ||
var got = require('got'); | ||
var objectAssign = require('object-assign'); | ||
var Promise = require('pinkie-promise'); | ||
const got = require('got'); | ||
function ghGot(path, opts) { | ||
if (typeof path !== 'string') { | ||
return Promise.reject(new TypeError('Path should be a string')); | ||
return Promise.reject(new TypeError(`Expected 'path' to be a string, got ${typeof path}`)); | ||
} | ||
opts = objectAssign({json: true, endpoint: 'https://api.github.com/'}, opts); | ||
opts = Object.assign({json: true, endpoint: 'https://api.github.com/'}, opts); | ||
opts.headers = objectAssign({ | ||
opts.headers = Object.assign({ | ||
'accept': 'application/vnd.github.v3+json', | ||
@@ -18,7 +16,7 @@ 'user-agent': 'https://github.com/sindresorhus/gh-got' | ||
var env = process.env; | ||
var token = env.GITHUB_TOKEN || opts.token; | ||
const env = process.env; | ||
const token = env.GITHUB_TOKEN || opts.token; | ||
if (token) { | ||
opts.headers.authorization = 'token ' + token; | ||
opts.headers.authorization = `token ${token}`; | ||
} | ||
@@ -31,4 +29,4 @@ | ||
var endpoint = env.GITHUB_ENDPOINT ? env.GITHUB_ENDPOINT.replace(/[^/]$/, '$&/') : opts.endpoint; | ||
var url = /https?/.test(path) ? path : endpoint + path; | ||
const endpoint = env.GITHUB_ENDPOINT ? env.GITHUB_ENDPOINT.replace(/[^/]$/, '$&/') : opts.endpoint; | ||
const url = /https?/.test(path) ? path : endpoint + path; | ||
@@ -42,3 +40,3 @@ if (opts.stream) { | ||
var helpers = [ | ||
const helpers = [ | ||
'get', | ||
@@ -52,18 +50,10 @@ 'post', | ||
helpers.forEach(function (el) { | ||
ghGot[el] = function (url, opts) { | ||
return ghGot(url, objectAssign({}, opts, {method: el.toUpperCase()})); | ||
}; | ||
}); | ||
ghGot.stream = (url, opts) => ghGot(url, Object.assign({}, opts, {json: false, stream: true})); | ||
ghGot.stream = function (url, opts) { | ||
return ghGot(url, objectAssign({}, opts, {json: false, stream: true})); | ||
}; | ||
for (const x of helpers) { | ||
const method = x.toUpperCase(); | ||
ghGot[x] = (url, opts) => ghGot(url, Object.assign({}, opts, {method})); | ||
ghGot.stream[x] = (url, opts) => ghGot.stream(url, Object.assign({}, opts, {method})); | ||
} | ||
helpers.forEach(function (el) { | ||
ghGot.stream[el] = function (url, opts) { | ||
return ghGot.stream(url, objectAssign({}, opts, {method: el.toUpperCase()})); | ||
}; | ||
}); | ||
module.exports = ghGot; |
{ | ||
"name": "gh-got", | ||
"version": "2.4.0", | ||
"version": "3.0.0", | ||
"description": "Convenience wrapper for `got` to interact with the GitHub API", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -37,16 +37,12 @@ "scripts": { | ||
"dependencies": { | ||
"got": "^5.2.0", | ||
"object-assign": "^4.0.1", | ||
"pinkie-promise": "^2.0.0" | ||
"got": "^6.2.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"get-stream": "^1.0.0", | ||
"get-stream": "^2.0.0", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"ignores": [ | ||
"test.js" | ||
] | ||
"esnext": true | ||
} | ||
} |
@@ -25,3 +25,3 @@ # gh-got [![Build Status](https://travis-ci.org/sindresorhus/gh-got.svg?branch=master)](https://travis-ci.org/sindresorhus/gh-got) | ||
'accept': 'application/vnd.github.v3+json', | ||
'authorization': 'token ' + token | ||
'authorization': `token ${token}` | ||
} | ||
@@ -71,3 +71,3 @@ }).then(res => { | ||
Type: `string` | ||
Type: `string`<br> | ||
Default: `https://api.github.com/` | ||
@@ -82,2 +82,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
1
4848
42
+ Addedduplexer3@0.1.5(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedgot@6.7.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedunzip-response@2.0.1(transitive)
- Removedobject-assign@^4.0.1
- Removedpinkie-promise@^2.0.0
- Removedcore-util-is@1.0.3(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedgot@5.7.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedisarray@1.0.0(transitive)
- Removednode-status-codes@1.0.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtimed-out@3.1.3(transitive)
- Removedunzip-response@1.0.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedgot@^6.2.0