added callback support

This commit is contained in:
Philipp Kunz 2016-01-20 04:01:21 +01:00
parent 7a00a44a70
commit 2f4f325a86
5 changed files with 27 additions and 5 deletions

1
index.d.ts vendored
View File

@ -23,5 +23,6 @@ declare var remotezip: {
get: (options: {
from: string;
toPath: string;
cb?: any;
}) => void;
};

View File

@ -26,7 +26,7 @@ var remotezip = {
return;
}
;
plugins.gulp.task('default', function () {
plugins.gulp.task("remotezip", function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"], {
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
@ -35,6 +35,13 @@ var remotezip = {
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.task("default", ["remotezip"], function () {
plugins.beautylog.success("Download complete and archive extracted");
if (typeof options.cb == "function") {
options.cb();
}
;
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
}
};

View File

@ -3,5 +3,8 @@ var remotezip = require("./index.js");
var path = require("path");
remotezip.get({
from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
toPath: path.resolve("./test/")
toPath: path.resolve("./test/"),
cb: function () {
console.log("This is a callback");
}
});

View File

@ -4,7 +4,7 @@
var plugins = RemotezipPlugins.init();
var remotezip = {
get: function(options:{from:string,toPath:string}){
get: function(options:{from:string,toPath:string, cb?}){
if (!plugins.path.isAbsolute(options.toPath)) { //check wether supplied path is absolute
plugins.beautylog.error("Please supply remotezip with an absolute path");
@ -12,7 +12,7 @@ var remotezip = {
}
;
plugins.gulp.task('default', function () {
plugins.gulp.task("remotezip", function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"], {
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
@ -22,6 +22,13 @@ var remotezip = {
return stream;
});
plugins.gulp.task("default",["remotezip"], function(){
plugins.beautylog.success("Download complete and archive extracted");
if(typeof options.cb == "function"){
options.cb();
};
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
}
};

View File

@ -1,7 +1,11 @@
/// <reference path="./typings/tsd.d.ts" />
var remotezip = require("./index.js");
var path = require("path");
remotezip.get({
from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
toPath:path.resolve("./test/")
toPath:path.resolve("./test/"),
cb: function(){
console.log("This is a callback")
}
});