diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/vinyl-fs/lib/src/index.js | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) |
add node_modules to address #4364
Diffstat (limited to 'node_modules/vinyl-fs/lib/src/index.js')
-rw-r--r-- | node_modules/vinyl-fs/lib/src/index.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/node_modules/vinyl-fs/lib/src/index.js b/node_modules/vinyl-fs/lib/src/index.js new file mode 100644 index 000000000..06cbe754d --- /dev/null +++ b/node_modules/vinyl-fs/lib/src/index.js @@ -0,0 +1,62 @@ +'use strict'; + +var assign = require('object-assign'); +var through2 = require('through2'); +var gs = require('glob-stream'); +var duplexify = require('duplexify'); +var merge = require('merge-stream'); +var sourcemaps = require('gulp-sourcemaps'); +var filterSince = require('../filterSince'); +var isValidGlob = require('is-valid-glob'); + +var getContents = require('./getContents'); +var wrapWithVinylFile = require('./wrapWithVinylFile'); + +function src(glob, opt) { + var options = assign({ + read: true, + buffer: true, + stripBOM: true, + sourcemaps: false, + passthrough: false, + followSymlinks: true, + }, opt); + + // Don't pass `read` option on to through2 + var read = options.read !== false; + options.read = undefined; + + var inputPass; + + if (!isValidGlob(glob)) { + throw new Error('Invalid glob argument: ' + glob); + } + + var globStream = gs.create(glob, options); + + var outputStream = globStream + .pipe(wrapWithVinylFile(options)); + + if (options.since != null) { + outputStream = outputStream + .pipe(filterSince(options.since)); + } + + if (read) { + outputStream = outputStream + .pipe(getContents(options)); + } + + if (options.passthrough === true) { + inputPass = through2.obj(options); + outputStream = duplexify.obj(inputPass, merge(outputStream, inputPass)); + } + if (options.sourcemaps === true) { + outputStream = outputStream + .pipe(sourcemaps.init({ loadMaps: true })); + } + globStream.on('error', outputStream.emit.bind(outputStream, 'error')); + return outputStream; +} + +module.exports = src; |