From 363723fc84f7b8477592e0105aeb331ec9a017af Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Aug 2017 05:01:11 +0200 Subject: node_modules --- node_modules/zip-stream/index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'node_modules/zip-stream/index.js') diff --git a/node_modules/zip-stream/index.js b/node_modules/zip-stream/index.js index 0c3248bf8..acb5d0df2 100644 --- a/node_modules/zip-stream/index.js +++ b/node_modules/zip-stream/index.js @@ -60,6 +60,7 @@ ZipStream.prototype._normalizeFileData = function(data) { data = util.defaults(data, { type: 'file', name: null, + linkname: null, date: null, mode: null, store: this.options.store, @@ -67,11 +68,12 @@ ZipStream.prototype._normalizeFileData = function(data) { }); var isDir = data.type === 'directory'; + var isSymlink = data.type === 'symlink'; if (data.name) { data.name = util.sanitizePath(data.name); - if (data.name.slice(-1) === '/') { + if (!isSymlink && data.name.slice(-1) === '/') { isDir = true; data.type = 'directory'; } else if (isDir) { @@ -79,7 +81,7 @@ ZipStream.prototype._normalizeFileData = function(data) { } } - if (isDir) { + if (isDir || isSymlink) { data.store = true; } @@ -110,7 +112,7 @@ ZipStream.prototype.entry = function(source, data, callback) { data = this._normalizeFileData(data); - if (data.type !== 'file' && data.type !== 'directory') { + if (data.type !== 'file' && data.type !== 'directory' && data.type !== 'symlink') { callback(new Error(data.type + ' entries not currently supported')); return; } @@ -120,6 +122,11 @@ ZipStream.prototype.entry = function(source, data, callback) { return; } + if (data.type === 'symlink' && typeof data.linkname !== 'string') { + callback(new Error('entry linkname must be a non-empty string value when type equals symlink')); + return; + } + var entry = new ZipArchiveEntry(data.name); entry.setTime(data.date); @@ -131,10 +138,22 @@ ZipStream.prototype.entry = function(source, data, callback) { entry.setComment(data.comment); } + if (data.type === 'symlink' && typeof data.mode !== 'number') { + data.mode = 40960; // 0120000 + } + if (typeof data.mode === 'number') { + if (data.type === 'symlink') { + data.mode |= 40960; + } + entry.setUnixMode(data.mode); } + if (data.type === 'symlink' && typeof data.linkname === 'string') { + source = new Buffer(data.linkname); + } + return ZipArchiveOutputStream.prototype.entry.call(this, entry, source, callback); }; -- cgit v1.2.3