Socket
Socket
Sign inDemoInstall

archiver

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

archiver - npm Package Compare versions

Comparing version 0.13.1 to 0.14.0

50

lib/core.js

@@ -31,2 +31,3 @@ /**

this._module = false;
this._pending = 0;
this._pointer = 0;

@@ -96,2 +97,15 @@

Archiver.prototype._maybeFinalize = function() {
if (this._state.finalizing || this._state.finalized || this._state.aborted) {
return false;
}
if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
this._finalize();
return true;
}
return false;
};
Archiver.prototype._moduleAppend = function(source, data, callback) {

@@ -142,5 +156,5 @@ if (this._state.aborted) {

Archiver.prototype._moduleSupports = function(key) {
this._module.supports = util.defaults(this._module.supports, {
directory: false
});
if (!this._module.supports || !this._module.supports[key]) {
return false;
}

@@ -208,3 +222,3 @@ return this._module.supports[key];

if (this._state.finalize && this._queue.idle() && this._statQueue.idle()) {
if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
this._finalize();

@@ -367,2 +381,28 @@ return;

Archiver.prototype.directory = function(dirpath) {
if (this._state.finalize || this._state.aborted) {
this.emit('error', new Error('directory: queue closed'));
return this;
}
this._pending++;
var self = this;
util.walkdir(dirpath, function(err, results) {
if (err) {
self.emit('error', err);
} else {
results.forEach(function(file) {
self._append(file.path, { stats: file.stats });
});
}
self._pending--;
self._maybeFinalize();
});
return this;
};
Archiver.prototype.file = function(filepath, data) {

@@ -397,3 +437,3 @@ if (this._state.finalize || this._state.aborted) {

if (this._queue.idle() && this._statQueue.idle()) {
if (this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
this._finalize();

@@ -400,0 +440,0 @@ }

@@ -103,2 +103,42 @@ /**

return filepath.replace(/\\/g, '/');
};
util.walkdir = function(dirpath, callback) {
var results = [];
dirpath = util.sanitizePath(dirpath);
dirpath = util.trailingSlashIt(dirpath);
fs.readdir(dirpath, function(err, list) {
var i = 0;
var file;
if (err) {
return callback(err);
}
(function next() {
file = list[i++];
if (!file) {
return callback(null, results);
}
fs.stat(dirpath + file, function (err, stats) {
results.push({
path: dirpath + file,
stats: stats
});
if (stats && stats.isDirectory()) {
util.walkdir(dirpath + file, function(err, res) {
results = results.concat(res);
next();
});
} else {
next();
}
});
})();
});
};

5

package.json
{
"name": "archiver",
"version": "0.13.1",
"version": "0.14.0",
"description": "a streaming interface for archive generation",

@@ -33,3 +33,4 @@ "homepage": "https://github.com/ctalkington/node-archiver",

"test": "mocha --reporter dot",
"bench": "node benchmark/simple/pack-zip.js"
"bencha": "node benchmark/simple/pack-zip.js",
"benchb": "mocha --reporter list test/optional/bench.js"
},

@@ -36,0 +37,0 @@ "dependencies": {

@@ -1,2 +0,2 @@

# Archiver v0.13.1 [![Build Status](https://travis-ci.org/ctalkington/node-archiver.svg?branch=master)](https://travis-ci.org/ctalkington/node-archiver)
# Archiver v0.14.0 [![Build Status](https://travis-ci.org/ctalkington/node-archiver.svg?branch=master)](https://travis-ci.org/ctalkington/node-archiver)

@@ -70,2 +70,10 @@ a streaming interface for archive generation

#### directory(dirpath)
Appends a directory, recusively, given its dirpath.
```js
archive.directory('mydir');
```
#### file(filepath, data)

@@ -72,0 +80,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc