From 666e615b5a5d61785ec7f619a7f2014c56973485 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Wed, 20 Jan 2016 03:30:03 +0100 Subject: [PATCH] restructure code --- index.d.ts | 10 ++++++---- index.js | 32 +++++++++++++++++--------------- test.js | 5 ++++- ts/index.ts | 34 ++++++++++++++++++---------------- ts/test.ts | 5 ++++- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5591aa3..c5647eb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; +}; diff --git a/index.js b/index.js index 30edd66..520ca75 100644 --- a/index.js +++ b/index.js @@ -19,21 +19,23 @@ var RemotezipPlugins; /// /// 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; diff --git a/test.js b/test.js index 108b857..4971390 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,7 @@ /// 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/") +}); diff --git a/ts/index.ts b/ts/index.ts index 4dffa0e..56f0c35 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -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; \ No newline at end of file diff --git a/ts/test.ts b/ts/test.ts index 28864e9..cce40b9 100644 --- a/ts/test.ts +++ b/ts/test.ts @@ -1,4 +1,7 @@ /// var remotezip = require("./index.js"); var path = require("path"); -remotezip({from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip",toPath:path.resolve("./test/")}); \ No newline at end of file +remotezip.get({ + from:"https://github.com/UmbrellaZone/legaldocs/archive/master.zip", + toPath:path.resolve("./test/") +}); \ No newline at end of file