forked from EvanOxfeld/node-unzip
-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathparseCompressedDirectory.js
41 lines (36 loc) · 1.25 KB
/
parseCompressedDirectory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const test = require('tap').test;
const fs = require('fs');
const path = require('path');
const temp = require('temp');
const dirdiff = require('dirdiff');
const unzip = require('../');
/*
zipinfo testData/compressed-directory-entry/archive.zip | grep META-INF/
?rwxr-xr-x 2.0 unx 0 b- defN 17-Sep-09 20:43 META-INF/
?rw------- 2.0 unx 244 b- defN 17-Sep-09 20:43 META-INF/container.xml
*/
test("extract compressed archive w/ a compressed directory entry", function (t) {
const archive = path.join(__dirname, '../testData/compressed-directory-entry/archive.zip');
temp.mkdir('node-unzip-', function (err, dirPath) {
if (err) {
throw err;
}
const unzipExtractor = unzip.Extract({ path: dirPath });
unzipExtractor.on('error', function(err) {
throw err;
});
unzipExtractor.on('close', testExtractionResults);
fs.createReadStream(archive).pipe(unzipExtractor);
function testExtractionResults() {
dirdiff(path.join(__dirname, '../testData/compressed-directory-entry/inflated'), dirPath, {
fileContents: true
}, function (err, diffs) {
if (err) {
throw err;
}
t.equal(diffs.length, 0, 'extracted directory contents');
t.end();
});
}
});
});