Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zip-dir

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zip-dir - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

4

index.js

@@ -29,2 +29,5 @@ var fs = require('fs');

var folders = {};
// Resolve the path so we can remove trailing slash if provided
rootDir = path.resolve(rootDir);
folders[rootDir] = zip;

@@ -44,2 +47,3 @@

if (err) return callback(err);
if (!files.length) return callback();
var count = files.length;

@@ -46,0 +50,0 @@ files.forEach(function (file) {

2

package.json
{
"name": "zip-dir",
"version": "0.1.3",
"version": "0.1.4",
"description": "Zips up directories into buffers or saves zipped files to disk",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,2 +13,4 @@ var Zip = require('../jszip');

var outputPath = path.join(__dirname, 'myxpi/');
var emptyDirPath = path.join(sampleZipPath, 'emptyDir');
var emptyDirOutputPath = path.join(outputPath, 'emptyDir');

@@ -18,2 +20,3 @@ describe('zip-dir', function () {

it('returns a usable zip buffer', function (done) {
console.log(sampleZipPath);
zipDir(sampleZipPath, function (err, buffer) {

@@ -26,2 +29,11 @@ expect(err).to.not.be.ok;

});
it('works with a trailing `/` in the path', function (done) {
zipDir(path.join(sampleZipPath, path.sep), function (err, buffer) {
expect(err).to.not.be.ok;
var zip = new Zip();
zip.load(buffer);
done();
});
});

@@ -35,3 +47,3 @@ it('returns an error when dirPath doesn\'t exist', function (done) {

});
it('returns an error when dirPath is a file', function (done) {

@@ -47,4 +59,9 @@ zipDir(path.join(sampleZipPath, 'file1.json'), function (err, buffer) {

describe('writes a zip file', function () {
beforeEach(zipAndUnzip);
beforeEach(function (done) {
addEmpty(function () {
zipAndUnzip(done);
});
});
afterEach(cleanUp);
it('compresses and unpacks and all files match', function (done) {

@@ -61,2 +78,10 @@ var files = [

});
it('retains empty directories', function (done) {
fs.stat(emptyDirOutputPath, function (err, stat) {
expect(err).to.not.be.ok;
expect(stat.isDirectory()).to.be.ok;
done();
});
});
});

@@ -82,4 +107,11 @@ });

fs.remove(outputPath, function () {
fs.remove(xpiPath, done);
fs.remove(xpiPath, function () {
fs.remove(emptyDirPath, done);
});
});
}
// Adds an empty directory for testing
function addEmpty (done) {
fs.mkdirp(emptyDirPath, done);
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc