now handling gulp streams allright
This commit is contained in:
@ -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
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user