fetch-remote
Advanced tools
Comparing version 1.0.3 to 1.0.4
38
index.js
@@ -6,20 +6,44 @@ #!/usr/bin/env node | ||
var request = require('request'); | ||
//var AdmZip = require('adm-zip'); | ||
var AdmZip = require('adm-zip'); | ||
var http = require('http'); | ||
var url = require('url'); | ||
function download( url, dest ){ | ||
url = url || "https://github.com/JDC-FD/gulp-tasks/archive/master.zip"; | ||
dest = dest || "gulp_tasks.zip"; | ||
/** | ||
* 从指定url下载zip包 | ||
* @param {[string]} url [拉取的zip包的路径] | ||
* @param {[strong]} dest [本地放置拉取的zip包名字] | ||
*/ | ||
function download( url, dest, cb ){ | ||
request({url: url, encoding: null}, function(err, resp, body) { | ||
if(err) throw err; | ||
fs.writeFile(output, body, function(err) { | ||
fs.writeFile(dest, body, function(err) { | ||
console.log("file written!"); | ||
if( cb ){ | ||
cb( err ); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* 解压文件到执行目录 | ||
* @param {[string]} source [解压文件名字] | ||
* @param {string} dest [解压位置] | ||
* @param {boolean} isOverWrite [是否覆盖] | ||
*/ | ||
function extract( source, dest, isOverWrite ){ | ||
dest = dest || './'; | ||
isOverWrite = isOverWrite || true; | ||
var zip = new AdmZip( source ); | ||
zip.extractAllTo(dest, isOverWrite); | ||
} | ||
function rename( oldPath, newPath, cb ){ | ||
fs.rename(oldPath, newPath, cb); | ||
} | ||
return { | ||
download: download | ||
download: download, | ||
extract: extract, | ||
rename: rename | ||
} | ||
@@ -26,0 +50,0 @@ |
{ | ||
"name": "fetch-remote", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "远程拉取文件,批量替换本地对应文件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
2380
3
45
1
37