Comparing version 0.1.15 to 0.1.16
28
cli.js
@@ -18,2 +18,4 @@ #!/usr/bin/env node | ||
help: Boolean, | ||
out: String, | ||
strip: Number, | ||
version: Boolean | ||
@@ -23,2 +25,4 @@ }, { | ||
h: '--help', | ||
o: '--out', | ||
s: '--strip', | ||
v: '--version' | ||
@@ -35,11 +39,13 @@ }); | ||
console.log('Usage'); | ||
console.log(' $ download <url> <path>'); | ||
console.log(' $ cat <file> | download <path>'); | ||
console.log(' $ download <url>'); | ||
console.log(' $ cat <file> | download>'); | ||
console.log(''); | ||
console.log('Example'); | ||
console.log(' $ download https://github.com/kevva/download/archive/master.zip files'); | ||
console.log(' $ cat urls.txt | download files'); | ||
console.log(' $ download --out dist --extract https://github.com/kevva/download/archive/master.zip'); | ||
console.log(' $ cat urls.txt | download --out dist'); | ||
console.log(''); | ||
console.log('Options'); | ||
console.log(' -e, --extract Extract archive files on download'); | ||
console.log(' -e, --extract Extract archive files on download'); | ||
console.log(' -o, --out Path to download or extract the files to'); | ||
console.log(' -s, --strip <number> Strip path segments from root when extracting'); | ||
} | ||
@@ -71,5 +77,2 @@ | ||
var src = url(input.join(' ')); | ||
var dest = input.filter(function (i) { | ||
return !i.match(/(^|\s)((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi); | ||
}); | ||
@@ -81,8 +84,3 @@ if (src.length === 0) { | ||
if (dest.length === 0) { | ||
console.error('Specify a destination path'); | ||
return; | ||
} | ||
download(src, dest.join(''), { extract: opts.extract }) | ||
download(src, opts.out, { extract: opts.extract, strip: opts.strip }) | ||
.on('error', function (err) { | ||
@@ -92,3 +90,3 @@ throw err; | ||
.on('close', function () { | ||
console.log('Successfully downloaded ' + src.length + ' files to ' + path.resolve(dest.join(''))); | ||
console.log('Successfully downloaded ' + src.length + ' files to ' + path.resolve(opts.out)); | ||
}); | ||
@@ -95,0 +93,0 @@ } |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var path = require('path'); | ||
var request = require('request'); | ||
var through = require('through2'); | ||
@@ -31,2 +30,3 @@ | ||
var request = require('request'); | ||
var stream = through(); | ||
@@ -33,0 +33,0 @@ var strip = +opts.strip || '0'; |
{ | ||
"name": "download", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Download and extract files effortlessly", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,2 +0,2 @@ | ||
# download [![Build Status](https://secure.travis-ci.org/kevva/download.png?branch=master)](http://travis-ci.org/kevva/download) | ||
# download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download) | ||
@@ -98,11 +98,13 @@ > Download and extract files effortlessly in Node.js. | ||
Usage | ||
$ download <url> <path> | ||
$ cat <file> | download <path> | ||
$ download <url> | ||
$ cat <file> | download> | ||
Example | ||
$ download https://github.com/kevva/download/archive/master.zip files | ||
$ cat urls.txt | download files | ||
$ download --out dist --extract https://github.com/kevva/download/archive/master.zip | ||
$ cat urls.txt | download --out dist | ||
Options | ||
-e, --extract Extract archive files on download | ||
-e, --extract Extract archive files on download | ||
-o, --out Path to download or extract the files to | ||
-s, --strip <number> Strip path segments from root when extracting | ||
``` | ||
@@ -109,0 +111,0 @@ |
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
8289
114
164