Socket
Socket
Sign inDemoInstall

download

Package Overview
Dependencies
18
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.1.0

80

cli.js

@@ -5,5 +5,3 @@ #!/usr/bin/env node

var Download = require('./');
var input = process.argv.slice(2);
var nopt = require('nopt');
var pkg = require('./package.json');
var meow = require('meow');
var progress = require('download-status');

@@ -16,25 +14,5 @@ var stdin = require('get-stdin');

var opts = nopt({
extract: Boolean,
help: Boolean,
out: String,
strip: Number,
version: Boolean
}, {
e: '--extract',
h: '--help',
o: '--out',
s: '--strip',
v: '--version'
});
/**
* Help screen
*/
function help() {
console.log([
'',
' ' + pkg.description,
'',
var cli = meow({
requireInput: process.stdin.isTTY,
help: [
' Usage',

@@ -56,24 +34,19 @@ ' download <url>',

' -s, --strip <number> Strip leading paths from file names on extraction'
].join('\n'));
}
].join('\n')
}, {
boolean: [
'extract'
],
string: [
'out',
'strip'
],
alias: {
e: 'extract',
o: 'out',
s: 'strip'
}
});
/**
* Show help
*/
if (input.indexOf('-h') !== -1 || input.indexOf('--help') !== -1) {
help();
return;
}
/**
* Show package version
*/
if (input.indexOf('-v') !== -1 || input.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
/**
* Run

@@ -87,3 +60,3 @@ *

function run(src, dest) {
var download = new Download(opts);
var download = new Download(cli.flags);

@@ -116,15 +89,10 @@ src.forEach(download.get.bind(download));

if (process.stdin.isTTY) {
var src = opts.argv.remain;
var dest = opts.out;
var src = cli.input;
var dest = cli.flags.out;
if (!src.length) {
help();
return;
}
run(src, dest);
} else {
stdin(function (data) {
var src = opts.argv.remain;
var dest = opts.out;
var src = cli.input;
var dest = cli.flags.out;

@@ -131,0 +99,0 @@ [].push.apply(src, data.trim().split('\n'));

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

if (!(this instanceof Download)) {
return new Download();
return new Download(opts);
}

@@ -173,7 +173,3 @@

pipe.on('error', function (err) {
cb(err);
return;
});
pipe.on('error', cb);
pipe.pipe(end);

@@ -180,0 +176,0 @@ });

{
"name": "download",
"version": "3.0.1",
"version": "3.1.0",
"description": "Download and extract files effortlessly",

@@ -42,3 +42,3 @@ "license": "MIT",

"gulp-rename": "^1.2.0",
"nopt": "^3.0.1",
"meow": "^1.0.0",
"rc": "^0.5.1",

@@ -57,4 +57,4 @@ "request": "^2.34.0",

"gulp-tar": "^1.1.0",
"nock": "^0.47.0"
"nock": "^0.48.0"
}
}

@@ -22,3 +22,3 @@ # download [![Build Status](http://img.shields.io/travis/kevva/download.svg?style=flat)](https://travis-ci.org/kevva/download)

var download = new Download({ extract: true, strip: 1 })
var download = new Download({ extract: true, strip: 1, mode: '755' })
.get('http://example.com/foo.zip')

@@ -47,2 +47,4 @@ .get('http://example.com/cat.jpg')

Type: `String`
Add a file to download.

@@ -52,2 +54,4 @@

Type: `String`
Set the destination folder to where your files will be downloaded.

@@ -57,7 +61,10 @@

Rename your files using [gulp-rename](https://github.com/hparra/gulp-rename).
Takes a `String` or a `Function` as argument.
Type: `Function|String`
Rename your files using [gulp-rename](https://github.com/hparra/gulp-rename).
### .use(plugin)
Type: `Function`
Adds a plugin to the middleware stack.

@@ -67,2 +74,4 @@

Type: `Function`
Pipe your files through a transform stream (e.g a gulp plugin).

@@ -72,4 +81,11 @@

Type: `Function`
Downloads your files and returns an error if something has gone wrong.
#### cb(err, files, stream)
The callback will return an array of vinyl files in `files` and a Readable/Writable
stream in `stream`.
## Options

@@ -89,6 +105,5 @@

Type: `Number`
Default: `null`
Type: `String`
Set mode on the downloaded file.
Set mode on the downloaded file, i.e `{ mode: '755' }`.

@@ -95,0 +110,0 @@ ### strip

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc