diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/zip-stream/index.js | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/zip-stream/index.js')
-rw-r--r-- | node_modules/zip-stream/index.js | 25 |
1 files changed, 22 insertions, 3 deletions
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);
};
|