Comparing version 0.4.2 to 0.4.3
@@ -9,10 +9,10 @@ /** | ||
var tarArchiver = require('./archiver/tar'); | ||
var zipArchiver = require('./archiver/zip'); | ||
var ArchiverTar = require('./archiver/tar'); | ||
var ArchiverZip = require('./archiver/zip'); | ||
var archiver = module.exports = function(type, options) { | ||
if (type === 'zip') { | ||
return new zipArchiver(options); | ||
return new ArchiverZip(options); | ||
} else if (type === 'tar') { | ||
return new tarArchiver(options); | ||
return new ArchiverTar(options); | ||
} else { | ||
@@ -26,7 +26,7 @@ throw new Error('Unknown archive type'); | ||
archiver.createTar = function(options) { | ||
return new tarArchiver(options); | ||
return new ArchiverTar(options); | ||
}; | ||
archiver.createZip = function(options) { | ||
return new zipArchiver(options); | ||
return new ArchiverZip(options); | ||
}; |
@@ -17,2 +17,6 @@ /** | ||
var Archiver = module.exports = function(options) { | ||
options = util.defaults(options, { | ||
highWaterMark: 64 * 1024 | ||
}); | ||
Transform.call(this, options); | ||
@@ -24,3 +28,3 @@ | ||
finalized: false, | ||
eof: false, | ||
writableEndCalled: false, | ||
pointer: 0, | ||
@@ -31,2 +35,14 @@ file: {}, | ||
}; | ||
var catchEarlyExit = function() { | ||
if (this._readableState.endEmitted === false) { | ||
throw new Error('Process exited before Archiver could finish emitting data'); | ||
} | ||
}.bind(this); | ||
process.once('exit', catchEarlyExit); | ||
this.once('end', function() { | ||
process.removeListener('exit', catchEarlyExit); | ||
}); | ||
}; | ||
@@ -67,4 +83,4 @@ | ||
this._processFile(next.source, next.data, next.callback); | ||
} else if (this.archiver.finalized && this.archiver.eof === false) { | ||
this.archiver.eof = true; | ||
} else if (this.archiver.finalized && this.archiver.writableEndCalled === false) { | ||
this.archiver.writableEndCalled = true; | ||
this.end(); | ||
@@ -81,4 +97,2 @@ } else if (this.archiver.finalize && this.archiver.queue.length === 0) { | ||
this._processQueue(); | ||
//this.emit('error', new Error('method not implemented')); | ||
}; | ||
@@ -114,3 +128,3 @@ | ||
if (typeof callback === 'function') { | ||
this.on('end', function() { | ||
this.once('end', function() { | ||
callback(null, this.archiver.pointer); | ||
@@ -117,0 +131,0 @@ }.bind(this)); |
@@ -15,4 +15,4 @@ /** | ||
var tarArchiver = module.exports = function(options) { | ||
Archiver.call(this); | ||
var ArchiverTar = module.exports = function(options) { | ||
Archiver.call(this, options); | ||
@@ -28,5 +28,5 @@ options = this.options = util.defaults(options, { | ||
inherits(tarArchiver, Archiver); | ||
inherits(ArchiverTar, Archiver); | ||
tarArchiver.prototype._flush = function(callback) { | ||
ArchiverTar.prototype._flush = function(callback) { | ||
var endBytes = this.blockSize - (this.archiver.pointer % this.blockSize); | ||
@@ -39,3 +39,3 @@ | ||
tarArchiver.prototype._processFile = function(source, data, callback) { | ||
ArchiverTar.prototype._processFile = function(source, data, callback) { | ||
var self = this; | ||
@@ -42,0 +42,0 @@ self.archiver.processing = true; |
@@ -17,4 +17,4 @@ /** | ||
var zipArchiver = module.exports = function(options) { | ||
Archiver.call(this); | ||
var ArchiverZip = module.exports = function(options) { | ||
Archiver.call(this, options); | ||
@@ -28,7 +28,12 @@ options = this.options = util.defaults(options, { | ||
}); | ||
if (options.level && options.level > 0) { | ||
options.zlib.level = options.level; | ||
delete options.level; | ||
} | ||
}; | ||
inherits(zipArchiver, Archiver); | ||
inherits(ArchiverZip, Archiver); | ||
zipArchiver.prototype._flush = function(callback) { | ||
ArchiverZip.prototype._flush = function(callback) { | ||
this._push(this._buildCentralDirectory()); | ||
@@ -39,3 +44,3 @@ | ||
zipArchiver.prototype._buildCentralDirectory = function() { | ||
ArchiverZip.prototype._buildCentralDirectory = function() { | ||
var files = this.archiver.files; | ||
@@ -78,3 +83,3 @@ var comment = this.options.comment; | ||
zipArchiver.prototype._processFile = function(source, data, callback) { | ||
ArchiverZip.prototype._processFile = function(source, data, callback) { | ||
var self = this; | ||
@@ -81,0 +86,0 @@ self.archiver.processing = true; |
@@ -15,7 +15,7 @@ var zlib = require('zlib'); | ||
this.on('data', function (chunk) { | ||
this.on('data', function(chunk) { | ||
this.compressedSize += chunk.length; | ||
}); | ||
this.on('end', function () { | ||
this.on('end', function() { | ||
this.digest = this.checksum.digest(); | ||
@@ -27,3 +27,3 @@ }); | ||
DeflateRawChecksum.prototype.write = function (chunk, cb) { | ||
DeflateRawChecksum.prototype.write = function(chunk, cb) { | ||
if (chunk) { | ||
@@ -30,0 +30,0 @@ this.checksum.update(chunk); |
{ | ||
"name": "archiver", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Creates Archives (ZIP) via Node Streams.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-archiver", |
@@ -1,2 +0,2 @@ | ||
# Archiver v0.4.2 [![Build Status](https://secure.travis-ci.org/ctalkington/node-archiver.png?branch=master)](http://travis-ci.org/ctalkington/node-archiver) | ||
# Archiver v0.4.3 [![Build Status](https://secure.travis-ci.org/ctalkington/node-archiver.png?branch=master)](http://travis-ci.org/ctalkington/node-archiver) | ||
@@ -3,0 +3,0 @@ Creates Archives (Zip, Tar) via Node Streams. Depends on Node's build-in zlib module for compression available since version 0.6.3. |
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
55006
1317