Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

download

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

download - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

25

download.js

@@ -9,3 +9,3 @@ 'use strict';

var request = require('request');
var stream = require('through2')();
var through = require('through2');

@@ -29,8 +29,11 @@ /**

url = Array.isArray(url) ? url : [url];
opts = opts || {};
var stream = through();
var strip = opts.strip || '0';
var target;
eachAsync(url, function (url, index, done) {
opts = opts || {};
opts.url = url;
opts.dest = path.join(dest, path.basename(url));
opts.strip = opts.strip || '0';
target = path.join(dest, path.basename(url));

@@ -55,2 +58,3 @@ var req = request.get(opts)

stream.emit('error', status);
return;
}

@@ -67,3 +71,7 @@

end = decompress.extract({ ext: ext, path: dest, strip: opts.strip });
end = decompress.extract({
ext: ext,
path: dest,
strip: strip
});
} else {

@@ -74,3 +82,3 @@ if (!fs.existsSync(dest)) {

end = fs.createWriteStream(opts.dest);
end = fs.createWriteStream(target);
}

@@ -82,9 +90,10 @@

if (!opts.extract && opts.mode) {
fs.chmodSync(opts.dest, opts.mode);
fs.chmodSync(target, opts.mode);
}
stream.emit('close');
done();
});
});
}, function () {
stream.emit('close');
});

@@ -91,0 +100,0 @@

{
"name": "download",
"version": "0.1.7",
"version": "0.1.8",
"description": "Download and extract files effortlessly",

@@ -28,15 +28,16 @@ "keywords": [

"dependencies": {
"decompress": "~0.1.0",
"decompress": "~0.1.5",
"each-async": "~0.1.1",
"mkdirp": "~0.3.5",
"request": "~2.25.0",
"through2": "~0.1.0"
"nock": "~0.27.1",
"request": "~2.31.0",
"through2": "~0.4.0"
},
"devDependencies": {
"mocha": "~1.12.0",
"rimraf": "~2.2.2"
"mocha": "~1.17.0",
"rimraf": "~2.2.5"
},
"engines": {
"node": ">=0.8.0"
"node": ">=0.10.0"
}
}

@@ -11,3 +11,3 @@ # download [![Build Status](https://secure.travis-ci.org/kevva/download.png?branch=master)](http://travis-ci.org/kevva/download)

If you're fetching an archive you can set `extract: true` in options and
If you're fetching an archive you can set `extract: true` in options and
it'll extract it for you.

@@ -34,14 +34,40 @@

Download a file or an array of files to a given destination. Returns an EventEmitter
with three possible events — `response`, `data` and `error`.
that emits the following possible events:
* `response` — Relayed when the underlying `http.ClientRequest` emits the same
event. Listeners called with a `http.IncomingMessage` instance.
* `data` — Relayed when the underlying `http.IncomingMessage` emits the same
event. Listeners called with a `Buffer` instance.
* `error` — Relayed when the underlying `http.ClientRequest` emits the same event
or when the response status code is not in the 200s. Listeners called with an
`Error` instance (in the first case) or the response status code.
* `close` — Relayed when the underlying `stream.Duplex` emits the same event.
## Options
* `extract` — If set to `true`, try extracting the file using [decompress](https://github.com/kevva/decompress/)
* `mode` — Set mode on the downloaded files
* `strip` — Equivalent to `--strip-components` for tar
You can define options accepted by the [request](https://github.com/mikeal/request/) module besides from the options below.
You can also define options accepted by the [request](https://github.com/mikeal/request/) module.
### extract
Type: `Boolean`
Default: `false`
If set to `true`, try extracting the file using [decompress](https://github.com/kevva/decompress/).
### mode
Type: `String`
Default: `undefined`
Set mode on the downloaded files.
### strip
Type: `Number`
Default: `0`
Equivalent to `--strip-components` for tar.
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License) (c) [Kevin Mårtensson](http://kevinmartensson.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc