restructure code

This commit is contained in:
Philipp Kunz 2016-01-20 03:30:03 +01:00
parent 7e8081d7b1
commit 666e615b5a
5 changed files with 49 additions and 37 deletions

10
index.d.ts vendored
View File

@ -19,7 +19,9 @@ declare var plugins: {
};
path: any;
};
declare var remotezip: (options: {
from: string;
toPath: string;
}) => void;
declare var remotezip: {
get: (options: {
from: string;
toPath: string;
}) => void;
};

View File

@ -19,21 +19,23 @@ var RemotezipPlugins;
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./remotezip.plugins.ts" />
var plugins = RemotezipPlugins.init();
var remotezip = function (options) {
if (!plugins.path.isAbsolute(options.toPath)) {
plugins.beautylog.error("Please supply remotezip with an absolute path");
return;
var remotezip = {
get: function (options) {
if (!plugins.path.isAbsolute(options.toPath)) {
plugins.beautylog.error("Please supply remotezip with an absolute path");
return;
}
;
plugins.gulp.task('default', function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"], {
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
}
;
plugins.gulp.task('default', function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"], {
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
};
module.exports = remotezip;

View File

@ -1,4 +1,7 @@
/// <reference path="./typings/tsd.d.ts" />
var remotezip = require("./index.js");
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/")
});

View File

@ -3,24 +3,26 @@
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
plugins.beautylog.error("Please supply remotezip with an absolute path");
return;
};
if (!plugins.path.isAbsolute(options.toPath)) { //check wether supplied path is absolute
plugins.beautylog.error("Please supply remotezip with an absolute path");
return;
}
;
plugins.gulp.task('default',function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"],{
base:"https://github.com/UmbrellaZone/legaldocs/archive/"
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.task('default', function () {
plugins.beautylog.log('Now trying to download and extract...');
var stream = plugins.g.remoteSrc(["master.zip"], {
base: "https://github.com/UmbrellaZone/legaldocs/archive/"
})
.pipe(plugins.g.unzip())
.pipe(plugins.gulp.dest(options.toPath));
return stream;
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
plugins.gulp.start.apply(plugins.gulp, ['default']);
}
};
module.exports = remotezip;

View File

@ -1,4 +1,7 @@
/// <reference path="./typings/tsd.d.ts" />
var remotezip = require("./index.js");
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/")
});