From abd94a7f5a50f43c797a11b53549ae48fff667c3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Oct 2016 03:43:44 +0200 Subject: add node_modules to address #4364 --- node_modules/vinyl-fs/lib/dest/index.js | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 node_modules/vinyl-fs/lib/dest/index.js (limited to 'node_modules/vinyl-fs/lib/dest/index.js') diff --git a/node_modules/vinyl-fs/lib/dest/index.js b/node_modules/vinyl-fs/lib/dest/index.js new file mode 100644 index 000000000..049ac9690 --- /dev/null +++ b/node_modules/vinyl-fs/lib/dest/index.js @@ -0,0 +1,54 @@ +'use strict'; + +var through2 = require('through2'); +var sourcemaps = require('gulp-sourcemaps'); +var duplexify = require('duplexify'); +var sink = require('../sink'); +var prepareWrite = require('../prepareWrite'); +var writeContents = require('./writeContents'); + +function dest(outFolder, opt) { + if (!opt) { + opt = {}; + } + + function saveFile(file, enc, cb) { + prepareWrite(outFolder, file, opt, function(err, writePath) { + if (err) { + return cb(err); + } + writeContents(writePath, file, cb); + }); + } + + var saveStream = through2.obj(opt, saveFile); + if (!opt.sourcemaps) { + // Sink the save stream to start flowing + // Do this on nextTick, it will flow at slowest speed of piped streams + process.nextTick(sink(saveStream)); + + return saveStream; + } + + var sourcemapOpt = opt.sourcemaps; + if (typeof sourcemapOpt === 'boolean') { + sourcemapOpt = {}; + } + if (typeof sourcemapOpt === 'string') { + sourcemapOpt = { + path: sourcemapOpt, + }; + } + + var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt); + var outputStream = duplexify.obj(mapStream, saveStream); + mapStream.pipe(saveStream); + + // Sink the output stream to start flowing + // Do this on nextTick, it will flow at slowest speed of piped streams + process.nextTick(sink(outputStream)); + + return outputStream; +} + +module.exports = dest; -- cgit v1.2.3