Skip to content

Commit

Permalink
Merge 8cf317d into 4c01544
Browse files Browse the repository at this point in the history
  • Loading branch information
zbinlin committed Jul 3, 2016
2 parents 4c01544 + 8cf317d commit 78a1cd6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function unzip(crxFilePath, destination) {
const isFile = !zip.files[filename].dir;
const fullPath = path.join(destination, filename);
const directory = isFile && path.dirname(fullPath) || fullPath;
const content = zip.files[filename].async("string");
const content = zip.files[filename].async("nodebuffer");

return mkdir(directory)
.then(() => isFile ? content : false)
Expand Down
Binary file modified test/fixtures/extension-zipped.crx
Binary file not shown.
2 changes: 2 additions & 0 deletions test/fixtures/extension/test.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Z����3=��_kkt���A���>�JL�B�(��,� �"H�2!�
�8�I�� *���=nޟ�x�
7 changes: 7 additions & 0 deletions test/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ describe("unzip-crx", () => {
});

it("should unpack the given regular zip file", (done) => {
const expectBinary = fs.readFileSync(
path.join(__dirname, "./fixtures/extension/test.bin")
);

const unzipPath = path.resolve(tempDir, "ext");
const readmeFile = path.resolve(tempDir, "ext/README.md");
const binaryFile = path.resolve(tempDir, "ext/test.bin");

unzip("./test/fixtures/extension-zipped.crx", unzipPath)
.then(() => {
const file = fs.readFileSync(readmeFile, "utf8");
const binaryContent = fs.readFileSync(binaryFile);

expect(file, "to equal", "# Crazy Readme File");
expect(binaryContent, "to equal", expectBinary);
done();
})
.catch((err) => done(err));
Expand Down

0 comments on commit 78a1cd6

Please sign in to comment.