added callback support
This commit is contained in:
parent
7a00a44a70
commit
2f4f325a86
1
index.d.ts
vendored
1
index.d.ts
vendored
@ -23,5 +23,6 @@ declare var remotezip: {
|
||||
get: (options: {
|
||||
from: string;
|
||||
toPath: string;
|
||||
cb?: any;
|
||||
}) => void;
|
||||
};
|
||||
|
9
index.js
9
index.js
@ -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']);
|
||||
}
|
||||
};
|
||||
|
5
test.js
5
test.js
@ -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");
|
||||
}
|
||||
});
|
||||
|
11
ts/index.ts
11
ts/index.ts
@ -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']);
|
||||
}
|
||||
};
|
||||
|
@ -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")
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user