Initial
This commit is contained in:
32
Client/node_modules/gulp-vinyl-zip/lib/dest/index.js
generated
vendored
Executable file
32
Client/node_modules/gulp-vinyl-zip/lib/dest/index.js
generated
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var through = require('through2');
|
||||
var vfs = require('vinyl-fs');
|
||||
var zip = require('../zip');
|
||||
var path = require('path');
|
||||
|
||||
function dest(zipPath, opts) {
|
||||
var input = zip(path.basename(zipPath), opts);
|
||||
var output = vfs.dest(path.dirname(zipPath), opts);
|
||||
|
||||
var stream = through.obj(function(file, enc, cb) {
|
||||
input.write(file);
|
||||
cb();
|
||||
}, function(cb) {
|
||||
input.end();
|
||||
output.on('end', function() {
|
||||
stream.end();
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
input.pipe(output);
|
||||
output.on('data', function(data) {
|
||||
stream.push(data);
|
||||
});
|
||||
|
||||
stream.resume();
|
||||
return stream;
|
||||
}
|
||||
|
||||
module.exports = dest;
|
||||
156
Client/node_modules/gulp-vinyl-zip/lib/src/index.js
generated
vendored
Executable file
156
Client/node_modules/gulp-vinyl-zip/lib/src/index.js
generated
vendored
Executable file
@@ -0,0 +1,156 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var yauzl = require('yauzl');
|
||||
var es = require('event-stream');
|
||||
var File = require('../vinyl-zip');
|
||||
var queue = require('queue');
|
||||
var constants = require('constants');
|
||||
|
||||
function modeFromEntry(entry) {
|
||||
var attr = entry.externalFileAttributes >> 16 || 33188;
|
||||
|
||||
return [448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */]
|
||||
.map(function(mask) { return attr & mask; })
|
||||
.reduce(function(a, b) { return a + b; }, attr & 61440 /* S_IFMT */);
|
||||
}
|
||||
|
||||
function mtimeFromEntry(entry) {
|
||||
return yauzl.dosDateTimeToDate(entry.lastModFileDate, entry.lastModFileTime);
|
||||
}
|
||||
|
||||
function toStream(zip) {
|
||||
var result = es.through();
|
||||
var q = queue();
|
||||
var didErr = false;
|
||||
|
||||
q.on('error', function (err) {
|
||||
didErr = true;
|
||||
result.emit('error', err);
|
||||
});
|
||||
|
||||
zip.on('entry', function (entry) {
|
||||
if (didErr) { return; }
|
||||
|
||||
var stat = new fs.Stats();
|
||||
stat.mode = modeFromEntry(entry);
|
||||
stat.mtime = mtimeFromEntry(entry);
|
||||
|
||||
// directories
|
||||
if (/\/$/.test(entry.fileName)) {
|
||||
stat.mode = (stat.mode & ~constants.S_IFMT) | constants.S_IFDIR;
|
||||
}
|
||||
|
||||
var file = {
|
||||
path: entry.fileName,
|
||||
stat: stat
|
||||
};
|
||||
|
||||
if (stat.isFile()) {
|
||||
if (entry.uncompressedSize === 0) {
|
||||
file.contents = new Buffer(0);
|
||||
result.emit('data', new File(file));
|
||||
|
||||
} else {
|
||||
q.push(function (cb) {
|
||||
zip.openReadStream(entry, function(err, readStream) {
|
||||
if (err) { return cb(err); }
|
||||
|
||||
file.contents = readStream;
|
||||
result.emit('data', new File(file));
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
q.start();
|
||||
}
|
||||
|
||||
} else if (stat.isSymbolicLink()) {
|
||||
q.push(function (cb) {
|
||||
zip.openReadStream(entry, function(err, readStream) {
|
||||
if (err) { return cb(err); }
|
||||
|
||||
file.symlink = '';
|
||||
readStream.on('data', function(c) { file.symlink += c; });
|
||||
readStream.on('error', cb);
|
||||
readStream.on('end', function () {
|
||||
result.emit('data', new File(file));
|
||||
cb();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
q.start();
|
||||
|
||||
} else if (stat.isDirectory()) {
|
||||
file.contents = null;
|
||||
result.emit('data', new File(file));
|
||||
|
||||
} else {
|
||||
result.emit('data', new File(file));
|
||||
}
|
||||
});
|
||||
|
||||
zip.on('end', function() {
|
||||
if (didErr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (q.length === 0) {
|
||||
result.end();
|
||||
} else {
|
||||
q.on('end', function () {
|
||||
result.end();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function unzipBuffer(contents) {
|
||||
var result = es.through();
|
||||
yauzl.fromBuffer(contents, function (err, zip) {
|
||||
if (err) { return result.emit('error', err); }
|
||||
toStream(zip).pipe(result);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function unzipFile(zipPath) {
|
||||
var result = es.through();
|
||||
yauzl.open(zipPath, function (err, zip) {
|
||||
if (err) { return result.emit('error', err); }
|
||||
toStream(zip).pipe(result);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function unzip() {
|
||||
var input = es.through();
|
||||
var result = es.through();
|
||||
var zips = [];
|
||||
|
||||
var output = input.pipe(es.through(function (f) {
|
||||
if (!f.isBuffer()) {
|
||||
this.emit('error', new Error('Only supports buffers'));
|
||||
}
|
||||
|
||||
zips.push(f);
|
||||
}, function () {
|
||||
var streams = zips.map(function (f) {
|
||||
return unzipBuffer(f.contents);
|
||||
});
|
||||
|
||||
es.merge(streams).pipe(result);
|
||||
this.emit('end');
|
||||
}));
|
||||
|
||||
return es.duplex(input, es.merge(output, result));
|
||||
}
|
||||
|
||||
function src(zipPath) {
|
||||
return zipPath ? unzipFile(zipPath) : unzip();
|
||||
}
|
||||
|
||||
module.exports = src;
|
||||
11
Client/node_modules/gulp-vinyl-zip/lib/vinyl-zip.js
generated
vendored
Executable file
11
Client/node_modules/gulp-vinyl-zip/lib/vinyl-zip.js
generated
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var File = require('vinyl');
|
||||
|
||||
class ZipFile extends File {
|
||||
constructor(file) {
|
||||
super(file);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ZipFile;
|
||||
60
Client/node_modules/gulp-vinyl-zip/lib/zip/index.js
generated
vendored
Executable file
60
Client/node_modules/gulp-vinyl-zip/lib/zip/index.js
generated
vendored
Executable file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var through = require('through2');
|
||||
var yazl = require('yazl');
|
||||
var File = require('../vinyl-zip');
|
||||
|
||||
function zip(zipPath, options) {
|
||||
if (!zipPath) throw new Error('No zip path specified.');
|
||||
|
||||
options = options || {};
|
||||
|
||||
var zip = new yazl.ZipFile();
|
||||
var isEmpty = true;
|
||||
|
||||
var stream = through.obj(function(file, enc, cb) {
|
||||
var stat = file.stat || {};
|
||||
|
||||
var opts = {
|
||||
mtime: stat.mtime,
|
||||
mode: stat.mode
|
||||
};
|
||||
|
||||
opts.compress = options.compress;
|
||||
|
||||
var path = file.relative.replace(/\\/g, '/');
|
||||
|
||||
if (stat.isSymbolicLink && stat.isSymbolicLink()) {
|
||||
zip.addBuffer(new Buffer(file.symlink), path, opts);
|
||||
} else if (file.isDirectory()) {
|
||||
// In Windows, directories have a 666 permissions. This doesn't go well
|
||||
// on OS X and Linux, where directories are expected to be 755.
|
||||
if (/win32/.test(process.platform)) {
|
||||
opts.mode = 16877;
|
||||
}
|
||||
|
||||
zip.addEmptyDirectory(path, opts);
|
||||
} else if (file.isBuffer()) {
|
||||
zip.addBuffer(file.contents, path, opts);
|
||||
} else if (file.isStream()) {
|
||||
zip.addReadStream(file.contents, path, opts);
|
||||
}
|
||||
|
||||
isEmpty = false;
|
||||
cb();
|
||||
}, function(cb) {
|
||||
if (isEmpty && options.unlessEmpty) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
stream.push(new File({path: zipPath, contents: zip.outputStream}));
|
||||
zip.end(function() {
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
stream.resume();
|
||||
return stream;
|
||||
}
|
||||
|
||||
module.exports = zip;
|
||||
Reference in New Issue
Block a user