Comparing version 0.1.6 to 0.1.7
'use strict'; | ||
var decompress = require('decompress'); | ||
var forEach = require('async-foreach').forEach; | ||
var eachAsync = require('each-async'); | ||
var fs = require('fs'); | ||
@@ -29,3 +29,3 @@ var mkdir = require('mkdirp'); | ||
forEach(url, function (url) { | ||
eachAsync(url, function (url, index, done) { | ||
opts = opts || {}; | ||
@@ -53,7 +53,15 @@ opts.url = url; | ||
if (status < 200 || status >= 300) { | ||
return; | ||
stream.emit('error', status); | ||
} | ||
if (opts.extract && decompress.canExtract(url, mime)) { | ||
end = decompress.extract({ ext: url, path: dest, strip: opts.strip }); | ||
var ext; | ||
if (decompress.canExtract(url)) { | ||
ext = url; | ||
} else { | ||
ext = mime; | ||
} | ||
end = decompress.extract({ ext: ext, path: dest, strip: opts.strip }); | ||
} else { | ||
@@ -75,2 +83,3 @@ if (!fs.existsSync(dest)) { | ||
stream.emit('close'); | ||
done(); | ||
}); | ||
@@ -77,0 +86,0 @@ }); |
{ | ||
"name": "download", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Download and extract files effortlessly", | ||
@@ -29,6 +29,6 @@ "keywords": [ | ||
"decompress": "~0.1.0", | ||
"each-async": "~0.1.1", | ||
"mkdirp": "~0.3.5", | ||
"request": "~2.25.0", | ||
"through2": "~0.1.0", | ||
"async-foreach": "~0.1.3" | ||
"through2": "~0.1.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "devDependencies": { |
@@ -32,3 +32,4 @@ # download [![Build Status](https://secure.travis-ci.org/kevva/download.png?branch=master)](http://travis-ci.org/kevva/download) | ||
Download a file or an array of files to a given destination. | ||
Download a file or an array of files to a given destination. Returns an EventEmitter | ||
with three possible events — `response`, `data` and `error`. | ||
@@ -35,0 +36,0 @@ ## Options |
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
4570
72
46
+ Addedeach-async@~0.1.1
+ Addedeach-async@0.1.3(transitive)
- Removedasync-foreach@~0.1.3
- Removedasync-foreach@0.1.3(transitive)