From b32e9b6b39c15889d31d4d328e1b66cdf944ed27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22piranna?= Date: Sun, 11 Oct 2015 19:28:28 +0200 Subject: [PATCH] Allow to stream symlink location if 'linkname' header field is not defined --- pack.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/pack.js b/pack.js index c9aade5..9b46127 100644 --- a/pack.js +++ b/pack.js @@ -112,15 +112,40 @@ Pack.prototype.entry = function(header, buffer, callback) { process.nextTick(callback) return new Void() } + + if (header.type === 'symlink' && !header.linkname) { + var stream = new Writable + var linkname = '' + + stream._write = function(data, enc, cb) + { + linkname += data + cb() + } + eos(stream, function(err) + { + if (err) { // stream was closed + self.destroy() + return callback(err) + } + + header.linkname = linkname + self._encode(header) + callback() + }) + + return stream + } + + this._encode(header) + if (header.type !== 'file' && header.type !== 'contigious-file') { - this._encode(header) process.nextTick(callback) return new Void() } var sink = new Sink(this) - this._encode(header) this._stream = sink eos(sink, function(err) {