/// "use strict"; var plugins = require("./smartfile.plugins"); var Readable = require("stream").Readable; /** * allows you to create a gulp stream from filestring * @param fileArg * @returns stream.Readable * @TODO: make it async; */ exports.toGulpStream = function (fileArg, baseArg) { var fileArray = []; if (typeof fileArg === "string" || fileArg instanceof plugins.vinyl) { fileArray.push(fileArg); } else if (Array.isArray(fileArg)) { fileArray = fileArg; } else { throw new Error("fileArg has unknown format"); } var vinylFileArray = []; //we want to have an array of vinylFiles for (var fileIndexArg in fileArray) { var file = fileArray[fileIndexArg]; file instanceof plugins.vinyl ? vinylFileArray.push(file) : vinylFileArray.push(exports.toVinylFileSync(file, { filename: fileIndexArg, base: "/" })); } ; var stream = new Readable({ objectMode: true }); for (var vinylFileIndexArg in vinylFileArray) { var vinylFile = vinylFileArray[vinylFileIndexArg]; stream.push(vinylFile); } ; stream.push(null); //signal end of stream; return stream; }; /** * takes a string and converts it to vinyl file * @param fileArg * @param optionsArg */ exports.toVinylFileSync = function (fileArg, optionsArg) { optionsArg ? void (0) : optionsArg = { filename: "vinylfile", base: "/" }; optionsArg.filename ? void (0) : optionsArg.filename = "vinylfile"; optionsArg.base ? void (0) : optionsArg.base = "/"; optionsArg.relPath ? void ("0") : optionsArg.relPath = ""; var vinylFile = new plugins.vinyl({ base: optionsArg.base, path: plugins.path.join(optionsArg.base, optionsArg.relPath, optionsArg.filename), contents: new Buffer(fileArg) }); return vinylFile; }; /** * takes a string array and some options and returns a vinylfile array * @param arrayArg * @param optionsArg */ exports.toVinylArraySync = function (arrayArg, optionsArg) { var vinylArray = []; for (var stringIndexArg in arrayArg) { var myString = arrayArg[stringIndexArg]; vinylArray.push(exports.toVinylFileSync(myString, optionsArg)); } return vinylArray; }; exports.toFs = function (fileArg, fileNameArg, fileBaseArg) { if (fileArg instanceof plugins.vinyl) { } }; exports.toFsSync = function () { }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5tZW1vcnkudHMiXSw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