提交 f45f279f 编写于 作者: NoSubject's avatar NoSubject

修改gulpfile,从gitlab下载commons和jvm

上级 7969d46e
......@@ -99,7 +99,7 @@ function ProgressBar(description, bar_length){
};
}
function downloadFile(path, filename, headcb, progresscb, cb){
function downloadFile_progress(path, filename, headcb, progresscb, cb){
var dest = `o2server/${filename}`;
// fs.exists(dest, function(exists) {
......@@ -144,7 +144,7 @@ function downloadFile(path, filename, headcb, progresscb, cb){
});
request.get(options).pipe(str).pipe(stream);
} else {
gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+response.statusCode);
gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+res.statusCode);
}
})
req.on('error', (e) => {
......@@ -154,6 +154,61 @@ function downloadFile(path, filename, headcb, progresscb, cb){
// }
//});
}
function downloadFile(path, filename, headcb, progresscb, cb){
var dest = `o2server/${filename}`;
// fs.exists(dest, function(exists) {
// if (exists){
// headcb(1);
// progresscb({transferred:1});
// cb();
// }else{
let stream = fs.createWriteStream(dest);
var options = { url:protocol+"://"+downloadHost+path };
var fileHost = downloadHost;
var filePath = path;
stream.on('finish', () => {
//gutil.log("download", ":", gutil.colors.green(filename), " completed!");
cb();
});
stream.on('error', (err) => {
gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), err);
});
// var req = http.request({
// host:fileHost,
// path:filePath,
// method:'HEAD'
// },function (res){
// if (res.statusCode == 200) {
// res.setEncoding(null);
// var time = 0;
// var l = res.headers['content-length'];
// var str = progress({
// length: l,
// time: 100 /* ms */
// });
// headcb(l);
//
// str.on('progress', function(progress) {
// if (pb){
// progresscb(progress);
// pb.render({ completed: currentLength, total: totalLength, time: time+=100 });
// }
//
// });
request.get(options).pipe(stream);
// } else {
// gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+res.statusCode);
// }
// })
// req.on('error', (e) => {
// gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), e);
// });
// req.end();
// }
//});
}
var commonsLength = 0;
var jvmLenght = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册