Comparing version 0.3.3 to 0.3.4
@@ -0,1 +1,5 @@ | ||
# v0.3.4 | ||
Released 6/1/2016 | ||
* Fixed bug reported in issue [#5](https://github.com/Mostafa-Samir/zip-local/issues/5) | ||
# v0.3.3 | ||
@@ -11,3 +15,3 @@ Released 4/22/2016 | ||
Released 4/12/2016 | ||
* Fixed bug reported in issue #4 | ||
* Fixed bug reported in issue [#4](https://github.com/Mostafa-Samir/zip-local/issues/4) | ||
@@ -14,0 +18,0 @@ # v0.3.0 |
@@ -60,9 +60,22 @@ var fs = require('graceful-fs'); | ||
fs.mkdir(extraction_path + dir, function (err) { | ||
// end of this iteration | ||
if(err) { | ||
//check first if the directory exists | ||
fs.stat(extraction_path + dir, function(err, stats) { | ||
if((err && err.code === "ENOENT") || !stats.isDirectory()) { | ||
// create the directory if it doesn't exist | ||
fs.mkdir(extraction_path + dir, function (err) { | ||
// end of this iteration | ||
if(err) { | ||
end_iteration(err); | ||
return; | ||
} | ||
end_iteration(); | ||
}); | ||
} | ||
else if(err && err.code !== "ENOENT") { | ||
end_iteration(err); | ||
return; | ||
} | ||
end_iteration(); | ||
else { | ||
end_iteration(); | ||
} | ||
}); | ||
@@ -149,3 +162,16 @@ | ||
dirs.forEach(function (dir) { | ||
fs.mkdirSync(extraction_path + dir); | ||
try { | ||
var stats = fs.statSync(extraction_path + dir); | ||
if(!stats.isDirectory()) { | ||
throw new Error("!dir"); | ||
} | ||
} | ||
catch(err) { | ||
if(err.code === "ENOENT" || err.message === "!dir") { | ||
fs.mkdirSync(extraction_path + dir); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
}); | ||
@@ -152,0 +178,0 @@ |
{ | ||
"name": "zip-local", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "very simple zipping/uzipping of local files and directories in node.js", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -92,2 +92,13 @@ var fs = require('fs'); | ||
}) | ||
it("uses existing folders without throwing EEXIST error", function(done) { | ||
zipper.unzip("./tests/assets/hello.zip", function(error, unzipped) { | ||
expect(error).to.be.null; | ||
unzipped.save("./tests/assets/hello-unzip-exists", function(error) { | ||
expect(error).to.be.null; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -10,10 +10,10 @@ var fs = require('fs'); | ||
describe("Unzipping synchronously", function () { | ||
it("unzips a .zip file in memory without errors", function () { | ||
localMemory.T1ZippedFS = zipper.sync.unzip("./tests/assets/hello.zip").memory(); | ||
}); | ||
it("checks if the ZippedFS object contains correct data", function () { | ||
expect(localMemory.T1ZippedFS.contents()).to.include("hello/says-hello") && | ||
@@ -24,25 +24,25 @@ expect(localMemory.T1ZippedFS.read("hello/says-hello", 'text')).to.equal("Hello") && | ||
}); | ||
it("unzips a .zip file to disk without errors", function () { | ||
fs.mkdirSync("./tests/assets/hello-sync-unzip"); | ||
zipper.sync.unzip("./tests/assets/hello.zip").save("./tests/assets/hello-sync-unzip/"); | ||
}); | ||
it("checks if unzipped files on disk contain correct data", function (done) { | ||
fs.readFile("./tests/assets/hello-sync-unzip/hello/says-hello", 'utf8', function (err, data) { | ||
if (err) | ||
throw err; | ||
expect(data).to.equal("Hello"); | ||
fs.readFile("./tests/assets/hello-sync-unzip/hello/world/says-world", 'utf8', function (err, world_data) { | ||
if (err) | ||
throw err; | ||
expect(world_data).to.equal("World"); | ||
done(); | ||
@@ -56,3 +56,3 @@ }); | ||
var buff = fs.readFileSync("./tests/assets/hello.zip"); | ||
localMemory.T5ZippedFS = zipper.sync.unzip(buff).memory(); | ||
@@ -62,3 +62,3 @@ }); | ||
it("checks if the ZippedFS object contains correct data", function () { | ||
expect(localMemory.T5ZippedFS.contents()).to.include("hello/says-hello") && | ||
@@ -70,2 +70,6 @@ expect(localMemory.T5ZippedFS.read("hello/says-hello", 'text')).to.equal("Hello") && | ||
}) | ||
it("uses existing folders without throwing EEXIST error", function() { | ||
zipper.sync.unzip("./tests/assets/hello.zip").save("./tests/assets/hello-unzip-exists"); | ||
}); | ||
}); |
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
55095
23
959