now working

This commit is contained in:
Philipp Kunz 2016-01-18 22:17:24 +01:00
parent 228a913e36
commit 11464d2eee
7 changed files with 92 additions and 5 deletions

21
index.d.ts vendored
View File

@ -1,6 +1,25 @@
/// <reference path="ts/typings/tsd.d.ts" />
declare module RemotezipPlugins {
var init: () => {
remotefile: any;
beautylog: any;
gulp: any;
g: {
unzip: any;
remoteSrc: any;
};
path: any;
};
}
declare var plugins: {
beautylog: any;
gulp: any;
g: {
unzip: any;
remoteSrc: any;
};
path: any;
};
declare var remotezip: (options: {
from: string;
toPath: string;
}) => void;

View File

@ -5,10 +5,35 @@ var RemotezipPlugins;
(function (RemotezipPlugins) {
RemotezipPlugins.init = function () {
var plugins = {
remotefile: require("remotefile")
beautylog: require("beautylog"),
gulp: require("gulp"),
g: {
unzip: require("gulp-unzip"),
remoteSrc: require("gulp-remote-src")
},
path: require("path")
};
return plugins;
};
})(RemotezipPlugins || (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;
}
;
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

@ -4,7 +4,8 @@
"description": "work with remote zip files",
"main": "index.js",
"scripts": {
"test": "(npmts)"
"test": "(npmts)",
"testm": "(npm test) && (node test.js)"
},
"repository": {
"type": "git",
@ -17,7 +18,11 @@
},
"homepage": "https://github.com/pushrocks/remotezip#readme",
"dependencies": {
"remotefile": "0.0.13"
"beautylog": "^2.0.2",
"gulp": "^3.9.0",
"gulp-remote-src": "^0.4.0",
"gulp-unzip": "^0.1.3",
"remotefile": "0.0.14"
},
"devDependencies": {
"npmts": "1.0.9"

4
test.js Normal file
View File

@ -0,0 +1,4 @@
/// <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/") });

View File

@ -1,2 +1,26 @@
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./remotezip.plugins.ts" />
var plugins = RemotezipPlugins.init();
var remotezip = 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;
};
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

@ -2,7 +2,13 @@
module RemotezipPlugins {
export var init = function() {
var plugins = {
remotefile: require("remotefile")
beautylog: require("beautylog"),
gulp: require("gulp"),
g:{
unzip: require("gulp-unzip"),
remoteSrc: require("gulp-remote-src")
},
path: require("path")
};
return plugins;
}

4
ts/test.ts Normal file
View File

@ -0,0 +1,4 @@
/// <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/")});