download
Advanced tools
Comparing version 6.2.2 to 6.2.3
27
index.js
@@ -16,8 +16,5 @@ 'use strict'; | ||
const fsP = pify(fs); | ||
const filenameFromPath = res => path.basename(url.parse(res.requestUrl).pathname); | ||
function filenameFromPath(res) { | ||
return path.basename(url.parse(res.requestUrl).pathname); | ||
} | ||
function getFilename(res) { | ||
const getFilename = res => { | ||
const header = res.headers['content-disposition']; | ||
@@ -27,2 +24,3 @@ | ||
const parsed = contentDisposition.parse(header); | ||
if (parsed.parameters && parsed.parameters.filename) { | ||
@@ -34,3 +32,3 @@ return parsed.parameters.filename; | ||
return filenameFromPath(res); | ||
} | ||
}; | ||
@@ -43,7 +41,2 @@ module.exports = (uri, output, opts) => { | ||
opts = Object.assign({ | ||
encoding: null, | ||
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false' | ||
}, opts); | ||
let protocol = url.parse(uri).protocol; | ||
@@ -55,4 +48,9 @@ | ||
opts = Object.assign({ | ||
encoding: null, | ||
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false' | ||
}, opts); | ||
const agent = caw(opts.proxy, {protocol}); | ||
const stream = got.stream(uri, Object.assign(opts, {agent})); | ||
const stream = got.stream(uri, Object.assign({agent}, opts)); | ||
@@ -68,6 +66,3 @@ const promise = pEvent(stream, 'response').then(res => { | ||
if (!output) { | ||
if (opts.extract) { | ||
return decompress(data, opts); | ||
} | ||
return data; | ||
return opts.extract ? decompress(data, opts) : data; | ||
} | ||
@@ -74,0 +69,0 @@ |
{ | ||
"name": "download", | ||
"version": "6.2.2", | ||
"version": "6.2.3", | ||
"description": "Download and extract files", | ||
@@ -34,6 +34,6 @@ "license": "MIT", | ||
"get-stream": "^3.0.0", | ||
"got": "^6.3.0", | ||
"got": "^7.0.0", | ||
"make-dir": "^1.0.0", | ||
"p-event": "^1.0.0", | ||
"pify": "^2.3.0" | ||
"pify": "^3.0.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
@@ -75,5 +75,11 @@ # download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download) | ||
##### proxy | ||
Type: `string` | ||
Proxy endpoint. | ||
## License | ||
MIT © [Kevin Mårtensson](https://github.com/kevva) |
5740
85
63
+ Addeddecompress-response@3.3.0(transitive)
+ Addedgot@7.1.0(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedp-cancelable@0.3.0(transitive)
- Removedcapture-stack-trace@1.0.2(transitive)
- Removedcreate-error-class@3.0.2(transitive)
- Removedgot@6.7.1(transitive)
- Removedis-redirect@1.0.0(transitive)
- Removedunzip-response@2.0.1(transitive)
Updatedgot@^7.0.0
Updatedpify@^3.0.0