smartfile/ts/smartfile.local.ts

65 lines
1.5 KiB
TypeScript
Raw Normal View History

import "typings-global";
2016-03-14 02:50:14 +00:00
import plugins = require("./smartfile.plugins");
import SmartfileGet = require("./smartfile.get");
import SmartfileInterpreter = require("./smartfile.interpreter");
2016-03-18 09:19:46 +00:00
export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
2016-03-14 02:50:14 +00:00
};
2016-03-19 21:07:59 +00:00
/**
*
* @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);
};
2016-03-14 02:50:14 +00:00
/**
*
* @param filePathArg
2016-03-14 02:50:14 +00:00
* @param fileTypeArg
* @returns {any}
*/
export let toObjectSync = function(filePathArg,fileTypeArg?) {
let fileString = plugins.fs.readFileSync(filePathArg, 'utf8');
2016-03-14 02:50:14 +00:00
let fileType;
fileTypeArg ? fileType = fileTypeArg : fileType = SmartfileGet.filetype(filePathArg);
return SmartfileInterpreter(fileString,fileType);
2016-03-14 02:50:14 +00:00
};
2016-03-18 09:19:46 +00:00
/**
* reads a file content to a String
* @param filePath
* @returns {string|Buffer|any}
*/
export let toStringSync = function(filePath) {
2016-03-18 09:19:46 +00:00
let fileString;
fileString = plugins.fs.readFileSync(filePath, "utf8");
return fileString;
};
2016-03-14 02:50:14 +00:00
/**
*
* @param filePathArg
* @param options
* @returns {number}
*/
export let toVinylSync = function(filePathArg,options = {}) {
2016-03-14 02:50:14 +00:00
return plugins.vinylFile.readSync(filePathArg,options);
};
/**
* lets you reload files hot.
* @param path
* @returns {any}
*/
export let requireReload = function(path:string){
return plugins.requireReload(path);
};