now handling gulp streams allright

This commit is contained in:
2016-03-19 22:07:59 +01:00
parent 4e62bbeeea
commit 9aac47cae3
11 changed files with 179 additions and 68 deletions

View File

@ -6,6 +6,20 @@ export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
};
/**
*
* @param filePathArg
* @returns {*}
*/
export let toGulpStreamSync = function(filePathArg:string){
let stream = plugins.gulp.src(filePathArg);
return stream;
};
export let toGulpDestSync = function(folderPathArg:string){
return plugins.gulp.dest(folderPathArg);
};
/**
*
* @param filePath

View File

@ -1,6 +1,10 @@
/// <reference path="./typings/main.d.ts" />
export let beautylog = require("beautylog");
export let fs = require("fs-extra");
export let gulp = require("gulp");
export let g = {
remoteSrc: require("gulp-remote-src")
};
export let path = require("path");
export let q = require("q");
export let vinyl = require("vinyl");

View File

@ -1,20 +1,32 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartfile.plugins");
export let toString = (fromArg:string) => {
let done = plugins.q.defer();
plugins.request.get(fromArg, function (error, response, bodyString) {
if (!error && response.statusCode == 200) {
done.resolve(bodyString);
} else {
plugins.beautylog.error('could not get get remote file from ' + fromArg);
bodyString = undefined;
done.reject(bodyString);
};
export let toFs = function(from:string,toPath:string) {
var done = plugins.q.defer();
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
stream.on('finish',function(){
done.resolve(toPath);
});
return done.promise;
};
/**
*
* @param filePathArg
* @returns {*}
*/
export let toGulpStreamSync = function(filePathArg:string,baseArg:string){
let stream = plugins.g.remoteSrc(filePathArg, {
base: baseArg
});
return stream;
};
/**
*
* @param fromArg
* @returns {any}
*/
export let toObject = function(fromArg:string){
let done = plugins.q.defer();
plugins.request.get(fromArg, function (error, response, bodyString) {
@ -31,11 +43,22 @@ export let toObject = function(fromArg:string){
return done.promise;
};
export let toFs = function(from:string,toPath:string) {
var done = plugins.q.defer();
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
stream.on('finish',function(){
done.resolve(toPath);
/**
*
* @param fromArg
* @returns {any}
*/
export let toString = (fromArg:string) => {
let done = plugins.q.defer();
plugins.request.get(fromArg, function (error, response, bodyString) {
if (!error && response.statusCode == 200) {
done.resolve(bodyString);
} else {
plugins.beautylog.error('could not get get remote file from ' + fromArg);
bodyString = undefined;
done.reject(bodyString);
};
});
return done.promise;
};
};