mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 12:31:52 -04:00
36 lines
673 B
JavaScript
36 lines
673 B
JavaScript
var debug = require('debug')('unpm:http')
|
|
var assign = require('object-assign')
|
|
|
|
/*
|
|
* Interface for 'got' with debug logging
|
|
*/
|
|
|
|
function got (url, options) {
|
|
debug(url)
|
|
return require('got')(url, extend(options))
|
|
}
|
|
|
|
/*
|
|
* like require('got').stream, but throated
|
|
*/
|
|
|
|
got.stream = function (url, options) {
|
|
debug(url)
|
|
return require('got').stream(url, extend(options))
|
|
}
|
|
|
|
/*
|
|
* Extends `got` options with User Agent headers and stuff
|
|
*/
|
|
|
|
function extend (options) {
|
|
if (!options) options = {}
|
|
return assign({}, options, {
|
|
headers: assign({}, options.headers || {}, {
|
|
'user-agent': 'https://github.com/rstacruz'
|
|
})
|
|
})
|
|
}
|
|
|
|
module.exports = got
|