Initial
This commit is contained in:
22
Client/node_modules/vinyl-fs/lib/src/getContents/bufferFile.js
generated
vendored
Executable file
22
Client/node_modules/vinyl-fs/lib/src/getContents/bufferFile.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
var stripBom = require('strip-bom');
|
||||
|
||||
function bufferFile(file, opt, cb) {
|
||||
fs.readFile(file.path, function(err, data) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (opt.stripBOM) {
|
||||
file.contents = stripBom(data);
|
||||
} else {
|
||||
file.contents = data;
|
||||
}
|
||||
|
||||
cb(null, file);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = bufferFile;
|
||||
31
Client/node_modules/vinyl-fs/lib/src/getContents/index.js
generated
vendored
Executable file
31
Client/node_modules/vinyl-fs/lib/src/getContents/index.js
generated
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var through2 = require('through2');
|
||||
var readDir = require('./readDir');
|
||||
var readSymbolicLink = require('./readSymbolicLink');
|
||||
var bufferFile = require('./bufferFile');
|
||||
var streamFile = require('./streamFile');
|
||||
|
||||
function getContents(opt) {
|
||||
return through2.obj(opt, function(file, enc, cb) {
|
||||
// Don't fail to read a directory
|
||||
if (file.isDirectory()) {
|
||||
return readDir(file, opt, cb);
|
||||
}
|
||||
|
||||
// Process symbolic links included with `followSymlinks` option
|
||||
if (file.stat && file.stat.isSymbolicLink()) {
|
||||
return readSymbolicLink(file, opt, cb);
|
||||
}
|
||||
|
||||
// Read and pass full contents
|
||||
if (opt.buffer !== false) {
|
||||
return bufferFile(file, opt, cb);
|
||||
}
|
||||
|
||||
// Don't buffer anything - just pass streams
|
||||
return streamFile(file, opt, cb);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getContents;
|
||||
8
Client/node_modules/vinyl-fs/lib/src/getContents/readDir.js
generated
vendored
Executable file
8
Client/node_modules/vinyl-fs/lib/src/getContents/readDir.js
generated
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
function readDir(file, opt, cb) {
|
||||
// Do nothing for now
|
||||
cb(null, file);
|
||||
}
|
||||
|
||||
module.exports = readDir;
|
||||
18
Client/node_modules/vinyl-fs/lib/src/getContents/readSymbolicLink.js
generated
vendored
Executable file
18
Client/node_modules/vinyl-fs/lib/src/getContents/readSymbolicLink.js
generated
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
|
||||
function readLink(file, opt, cb) {
|
||||
fs.readlink(file.path, function(err, target) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
// Store the link target path
|
||||
file.symlink = target;
|
||||
|
||||
return cb(null, file);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = readLink;
|
||||
26
Client/node_modules/vinyl-fs/lib/src/getContents/streamFile.js
generated
vendored
Executable file
26
Client/node_modules/vinyl-fs/lib/src/getContents/streamFile.js
generated
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
var stripBom = require('strip-bom-stream');
|
||||
var lazystream = require('lazystream');
|
||||
|
||||
function streamFile(file, opt, cb) {
|
||||
if (typeof opt === 'function') {
|
||||
cb = opt;
|
||||
opt = {};
|
||||
}
|
||||
|
||||
var filePath = file.path;
|
||||
|
||||
file.contents = new lazystream.Readable(function() {
|
||||
return fs.createReadStream(filePath);
|
||||
});
|
||||
|
||||
if (opt.stripBOM) {
|
||||
file.contents = file.contents.pipe(stripBom());
|
||||
}
|
||||
|
||||
cb(null, file);
|
||||
}
|
||||
|
||||
module.exports = streamFile;
|
||||
62
Client/node_modules/vinyl-fs/lib/src/index.js
generated
vendored
Executable file
62
Client/node_modules/vinyl-fs/lib/src/index.js
generated
vendored
Executable file
@@ -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;
|
||||
51
Client/node_modules/vinyl-fs/lib/src/wrapWithVinylFile.js
generated
vendored
Executable file
51
Client/node_modules/vinyl-fs/lib/src/wrapWithVinylFile.js
generated
vendored
Executable file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
var through2 = require('through2');
|
||||
var fs = require('graceful-fs');
|
||||
var File = require('vinyl');
|
||||
|
||||
function wrapWithVinylFile(options) {
|
||||
|
||||
// A stat property is exposed on file objects as a (wanted) side effect
|
||||
function resolveFile(globFile, enc, cb) {
|
||||
fs.lstat(globFile.path, function(err, stat) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
globFile.stat = stat;
|
||||
|
||||
if (!stat.isSymbolicLink() || !options.followSymlinks) {
|
||||
var vinylFile = new File(globFile);
|
||||
if (globFile.originalSymlinkPath) {
|
||||
// If we reach here, it means there is at least one
|
||||
// symlink on the path and we need to rewrite the path
|
||||
// to its original value.
|
||||
// Updated file stats will tell getContents() to actually read it.
|
||||
vinylFile.path = globFile.originalSymlinkPath;
|
||||
}
|
||||
return cb(null, vinylFile);
|
||||
}
|
||||
|
||||
fs.realpath(globFile.path, function(err, filePath) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (!globFile.originalSymlinkPath) {
|
||||
// Store the original symlink path before the recursive call
|
||||
// to later rewrite it back.
|
||||
globFile.originalSymlinkPath = globFile.path;
|
||||
}
|
||||
globFile.path = filePath;
|
||||
|
||||
// Recurse to get real file stat
|
||||
resolveFile(globFile, enc, cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return through2.obj(options, resolveFile);
|
||||
}
|
||||
|
||||
module.exports = wrapWithVinylFile;
|
||||
Reference in New Issue
Block a user