Comparing version
@@ -39,3 +39,4 @@ /** | ||
name: null, | ||
date: null | ||
date: null, | ||
sourcePath: null | ||
}); | ||
@@ -65,2 +66,6 @@ | ||
Archiver.prototype._onModuleError = function(err) { | ||
this.emit('error', err); | ||
}; | ||
Archiver.prototype._onQueueEnd = function() { | ||
@@ -98,2 +103,3 @@ if (typeof this._module.finalize === 'function') { | ||
Archiver.prototype._pipeModuleOutput = function() { | ||
this._module.on('error', this._onModuleError.bind(this)); | ||
this._module.pipe(this); | ||
@@ -153,3 +159,3 @@ | ||
var isExpandedPair = file.orig.expand || false; | ||
var data = file.data || {}; | ||
var fileData = file.data || {}; | ||
var src = file.src.filter(function(f) { | ||
@@ -160,5 +166,13 @@ return util.file.isFile(f); | ||
src.forEach(function(filepath) { | ||
data.name = isExpandedPair ? file.dest : util.unixifyPath(file.dest || '', filepath); | ||
var name = isExpandedPair ? file.dest : util.unixifyPath(file.dest || '', filepath); | ||
var data = util._.extend({}, fileData); | ||
self.append(util.lazyReadStream(filepath), data); | ||
data.name = util.sanitizePath(name); | ||
data.sourcePath = filepath; | ||
data.sourceType = 'stream'; | ||
self._queue.add({ | ||
data: data, | ||
source: util.lazyReadStream(filepath) | ||
}); | ||
}); | ||
@@ -172,3 +186,2 @@ }); | ||
data = this._normalizeFileData(data); | ||
filepath = String(filepath); | ||
@@ -182,6 +195,12 @@ if (typeof filepath !== 'string' || filepath.length === 0) { | ||
if (typeof data.name !== 'string' || data.name.length === 0) { | ||
data.name = filepath; | ||
data.name = util.sanitizePath(filepath); | ||
} | ||
this.append(util.lazyReadStream(filepath), data); | ||
data.sourcePath = filepath; | ||
data.sourceType = 'stream'; | ||
this._queue.add({ | ||
data: data, | ||
source: util.lazyReadStream(filepath) | ||
}); | ||
} else { | ||
@@ -188,0 +207,0 @@ this.emit('error', new Error('invalid file: ' + filepath)); |
@@ -37,2 +37,3 @@ /** | ||
this.compressor = zlib.createGzip(options.gzipOptions); | ||
this.compressor.on('error', this._onCompressorError.bind(this)); | ||
} | ||
@@ -43,2 +44,6 @@ }; | ||
Tar.prototype._onCompressorError = function(err) { | ||
this.emit('error', err); | ||
}; | ||
Tar.prototype._transform = function(chunk, encoding, callback) { | ||
@@ -45,0 +50,0 @@ callback(null, chunk); |
@@ -8,3 +8,2 @@ /** | ||
*/ | ||
var engine = require('zip-stream'); | ||
@@ -31,4 +30,8 @@ var util = require('../../util'); | ||
Zip.prototype.on = function() { | ||
return this.engine.on.apply(this.engine, arguments); | ||
}; | ||
Zip.prototype.pipe = function() { | ||
return this.engine.pipe.apply(this.engine, arguments); | ||
}; |
{ | ||
"name": "archiver", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Creates Archives (ZIP) via Node Streams.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-archiver", |
@@ -1,2 +0,2 @@ | ||
# Archiver v0.7.0 [](https://travis-ci.org/ctalkington/node-archiver) | ||
# Archiver v0.7.1 [](https://travis-ci.org/ctalkington/node-archiver) | ||
@@ -3,0 +3,0 @@ Creates Archives (Zip, Tar) via Node Streams. |
@@ -102,3 +102,3 @@ /*global before,describe,it */ | ||
.bulk([ | ||
{ expand: true, cwd: 'test/fixtures', src: 'directory/**' } | ||
{ expand: true, cwd: 'test/fixtures', src: 'directory/**', data: { prop: 'value' } } | ||
]) | ||
@@ -111,3 +111,10 @@ .finalize(); | ||
assert.lengthOf(actual, 3); | ||
assert.propertyVal(actual[0], 'name', 'directory/level0.txt'); | ||
assert.propertyVal(actual[1], 'name', 'directory/subdir/level1.txt'); | ||
assert.propertyVal(actual[2], 'name', 'directory/subdir/subsub/level2.txt'); | ||
}); | ||
it('should support passing data property', function() { | ||
assert.propertyVal(actual[0], 'prop', 'value'); | ||
}); | ||
}); | ||
@@ -114,0 +121,0 @@ |
Sorry, the diff of this file is not supported yet
77312
1.95%1543
1.92%