Comparing version 0.1.3 to 0.1.4
@@ -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) { |
{ | ||
"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); | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
141178
2332
0