restructure code
This commit is contained in:
parent
7e8081d7b1
commit
666e615b5a
6
index.d.ts
vendored
6
index.d.ts
vendored
@ -19,7 +19,9 @@ declare var plugins: {
|
|||||||
};
|
};
|
||||||
path: any;
|
path: any;
|
||||||
};
|
};
|
||||||
declare var remotezip: (options: {
|
declare var remotezip: {
|
||||||
|
get: (options: {
|
||||||
from: string;
|
from: string;
|
||||||
toPath: string;
|
toPath: string;
|
||||||
}) => void;
|
}) => void;
|
||||||
|
};
|
||||||
|
4
index.js
4
index.js
@ -19,7 +19,8 @@ var RemotezipPlugins;
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
/// <reference path="./remotezip.plugins.ts" />
|
/// <reference path="./remotezip.plugins.ts" />
|
||||||
var plugins = RemotezipPlugins.init();
|
var plugins = RemotezipPlugins.init();
|
||||||
var remotezip = function (options) {
|
var remotezip = {
|
||||||
|
get: function (options) {
|
||||||
if (!plugins.path.isAbsolute(options.toPath)) {
|
if (!plugins.path.isAbsolute(options.toPath)) {
|
||||||
plugins.beautylog.error("Please supply remotezip with an absolute path");
|
plugins.beautylog.error("Please supply remotezip with an absolute path");
|
||||||
return;
|
return;
|
||||||
@ -35,5 +36,6 @@ var remotezip = function (options) {
|
|||||||
return stream;
|
return stream;
|
||||||
});
|
});
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
module.exports = remotezip;
|
module.exports = remotezip;
|
||||||
|
5
test.js
5
test.js
@ -1,4 +1,7 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var remotezip = require("./index.js");
|
var remotezip = require("./index.js");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
remotezip({ from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip", toPath: path.resolve("./test/") });
|
remotezip.get({
|
||||||
|
from: "https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
|
||||||
|
toPath: path.resolve("./test/")
|
||||||
|
});
|
||||||
|
16
ts/index.ts
16
ts/index.ts
@ -3,17 +3,19 @@
|
|||||||
|
|
||||||
var plugins = RemotezipPlugins.init();
|
var plugins = RemotezipPlugins.init();
|
||||||
|
|
||||||
var remotezip = function(options:{from:string,toPath:string}){
|
var remotezip = {
|
||||||
|
get: function(options:{from:string,toPath:string}){
|
||||||
|
|
||||||
if(!plugins.path.isAbsolute(options.toPath)){ //check wether supplied path is absolute
|
if (!plugins.path.isAbsolute(options.toPath)) { //check wether supplied path is absolute
|
||||||
plugins.beautylog.error("Please supply remotezip with an absolute path");
|
plugins.beautylog.error("Please supply remotezip with an absolute path");
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
plugins.gulp.task('default',function () {
|
plugins.gulp.task('default', function () {
|
||||||
plugins.beautylog.log('Now trying to download and extract...');
|
plugins.beautylog.log('Now trying to download and extract...');
|
||||||
var stream = plugins.g.remoteSrc(["master.zip"],{
|
var stream = plugins.g.remoteSrc(["master.zip"], {
|
||||||
base:"https://github.com/UmbrellaZone/legaldocs/archive/"
|
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
|
||||||
})
|
})
|
||||||
.pipe(plugins.g.unzip())
|
.pipe(plugins.g.unzip())
|
||||||
.pipe(plugins.gulp.dest(options.toPath));
|
.pipe(plugins.gulp.dest(options.toPath));
|
||||||
@ -21,6 +23,6 @@ var remotezip = function(options:{from:string,toPath:string}){
|
|||||||
});
|
});
|
||||||
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = remotezip;
|
module.exports = remotezip;
|
@ -1,4 +1,7 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var remotezip = require("./index.js");
|
var remotezip = require("./index.js");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
remotezip({from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip",toPath:path.resolve("./test/")});
|
remotezip.get({
|
||||||
|
from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip",
|
||||||
|
toPath:path.resolve("./test/")
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user