Comparing version 0.2.1 to 0.2.2
@@ -197,3 +197,9 @@ var inherits = require('util').inherits; | ||
utils.collectStream(source, function(error, buffer) { | ||
if (error) { | ||
self.emit('error', 'stream collection failed'); | ||
return; | ||
} | ||
update(buffer); | ||
source = buffer; | ||
@@ -200,0 +206,0 @@ process.nextTick(onEnd); |
{ | ||
"name": "archiver", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Creates Archives (ZIP) via Node Streams.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-archiver", |
@@ -13,4 +13,6 @@ var crypto = require('crypto'); | ||
mkdir('tmp'); | ||
module.exports = { | ||
tarBuffer: function(test) { | ||
inputBuffer: function(test) { | ||
test.expect(1); | ||
@@ -55,4 +57,39 @@ | ||
tarString: function(test) { | ||
inputStream: function(test) { | ||
var actual; | ||
var expected = 'da02a931d670f725c0de20ef30b112b53d149a3d'; | ||
var hash = crypto.createHash('sha1'); | ||
var archive = archiver.createTar(); | ||
if (fileOutput) { | ||
rimraf.sync('tmp/stream.tar'); | ||
var out = fs.createWriteStream('tmp/stream.tar'); | ||
archive.pipe(out); | ||
} | ||
rimraf.sync('tmp/stream.txt'); | ||
fs.writeFileSync('tmp/stream.txt', 'this is a text file'); | ||
archive.addFile(fs.createReadStream('tmp/stream.txt'), {name: 'stream.txt', date: date1}, function() { | ||
archive.finalize(); | ||
}); | ||
archive.on('error', function(err) { | ||
throw err; | ||
}); | ||
archive.on('data', function(data) { | ||
hash.update(data); | ||
}); | ||
archive.on('end', function() { | ||
actual = hash.digest('hex'); | ||
test.equals(actual, expected, 'data hex values should match.'); | ||
test.done(); | ||
}); | ||
}, | ||
inputString: function(test) { | ||
var actual; | ||
var expected = '333f843838ba5ee7727b3cc8afa017cab3d70d72'; | ||
@@ -59,0 +96,0 @@ |
@@ -13,14 +13,14 @@ var crypto = require('crypto'); | ||
mkdir('tmp'); | ||
module.exports = { | ||
zipBuffer: function(test) { | ||
featureComments: function(test) { | ||
test.expect(1); | ||
var actual; | ||
var expected = 'b18540ab929d83f8ed6d419e6f306fa381aa1f4e'; | ||
var expected = 'b09223a2a00d21d84fd4d9a57a3a7fa451125146'; | ||
var hash = crypto.createHash('sha1'); | ||
var archive = archiver.createZip({ | ||
zlib: { | ||
level: 1 | ||
}, | ||
comment: 'this is a zip comment', | ||
forceUTC: true | ||
@@ -30,4 +30,4 @@ }); | ||
if (fileOutput) { | ||
rimraf.sync('tmp/buffer.zip'); | ||
var out = fs.createWriteStream('tmp/buffer.zip'); | ||
rimraf.sync('tmp/comments.zip'); | ||
var out = fs.createWriteStream('tmp/comments.zip'); | ||
archive.pipe(out); | ||
@@ -42,3 +42,3 @@ } | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1}, function() { | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1, comment: 'this is a file comment'}, function() { | ||
archive.finalize(); | ||
@@ -62,11 +62,10 @@ }); | ||
zipComments: function(test) { | ||
featureStore: function(test) { | ||
test.expect(1); | ||
var actual; | ||
var expected = 'b09223a2a00d21d84fd4d9a57a3a7fa451125146'; | ||
var expected = '09305770a3272cbcd7c151ee267cb1b0075dd29e'; | ||
var hash = crypto.createHash('sha1'); | ||
var archive = archiver.createZip({ | ||
comment: 'this is a zip comment', | ||
forceUTC: true | ||
@@ -76,7 +75,8 @@ }); | ||
if (fileOutput) { | ||
rimraf.sync('tmp/comments.zip'); | ||
var out = fs.createWriteStream('tmp/comments.zip'); | ||
rimraf.sync('tmp/store.zip'); | ||
var out = fs.createWriteStream('tmp/store.zip'); | ||
archive.pipe(out); | ||
} | ||
// create a buffer and fill it | ||
var buffer = new Buffer(20000); | ||
@@ -88,3 +88,3 @@ | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1, comment: 'this is a file comment'}, function() { | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1, store: true}, function() { | ||
archive.finalize(); | ||
@@ -108,10 +108,13 @@ }); | ||
zipStore: function(test) { | ||
inputBuffer: function(test) { | ||
test.expect(1); | ||
var actual; | ||
var expected = '09305770a3272cbcd7c151ee267cb1b0075dd29e'; | ||
var expected = 'b18540ab929d83f8ed6d419e6f306fa381aa1f4e'; | ||
var hash = crypto.createHash('sha1'); | ||
var archive = archiver.createZip({ | ||
zlib: { | ||
level: 1 | ||
}, | ||
forceUTC: true | ||
@@ -121,8 +124,7 @@ }); | ||
if (fileOutput) { | ||
rimraf.sync('tmp/store.zip'); | ||
var out = fs.createWriteStream('tmp/store.zip'); | ||
rimraf.sync('tmp/buffer.zip'); | ||
var out = fs.createWriteStream('tmp/buffer.zip'); | ||
archive.pipe(out); | ||
} | ||
// create a buffer and fill it | ||
var buffer = new Buffer(20000); | ||
@@ -134,3 +136,3 @@ | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1, store: true}, function() { | ||
archive.addFile(buffer, {name: 'buffer.txt', date: date1}, function() { | ||
archive.finalize(); | ||
@@ -154,6 +156,48 @@ }); | ||
zipString: function(test) { | ||
inputStream: function(test) { | ||
test.expect(1); | ||
var actual; | ||
var expected = 'd7e3970142a06d4a87fbd6458284eeaf8f5de907'; | ||
var hash = crypto.createHash('sha1'); | ||
var archive = archiver.createZip({ | ||
zlib: { | ||
level: 1 | ||
}, | ||
forceUTC: true | ||
}); | ||
if (fileOutput) { | ||
rimraf.sync('tmp/stream.zip'); | ||
var out = fs.createWriteStream('tmp/stream.zip'); | ||
archive.pipe(out); | ||
} | ||
rimraf.sync('tmp/stream.txt'); | ||
fs.writeFileSync('tmp/stream.txt', 'this is a text file'); | ||
archive.addFile(fs.createReadStream('tmp/stream.txt'), {name: 'stream.txt', date: date1}, function() { | ||
archive.finalize(); | ||
}); | ||
archive.on('error', function(err) { | ||
throw err; | ||
}); | ||
archive.on('data', function(data) { | ||
hash.update(data); | ||
}); | ||
archive.on('end', function() { | ||
actual = hash.digest('hex'); | ||
test.equals(actual, expected, 'data hex values should match.'); | ||
test.done(); | ||
}); | ||
}, | ||
inputString: function(test) { | ||
test.expect(1); | ||
var actual; | ||
var expected = '3de2c37ba3745618257f6816fe979ee565e24aa0'; | ||
@@ -160,0 +204,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43567
1094