Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@
throw error;
}

const strip = opts.strip ? Number(opts.strip) : 0;
// Strip is handled here in makeUncompressFn, so remove it from opts to avoid passing to UncompressStream
delete opts.strip;

return new Promise((resolve, reject) => {
fs.mkdir(destDir, { recursive: true }, err => {

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 96 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead
if (err) return reject(err);

let entryCount = 0;
Expand All @@ -108,11 +112,10 @@
.on('error', reject)
.on('entry', (header, stream, next) => {
stream.on('end', next);
const destFilePath = path.join(destDir, header.name);

const destFilePath = path.join(destDir, stripFileName(strip, header.name, header.type));
if (header.type === 'file') {
const dir = path.dirname(destFilePath);
fs.mkdir(dir, { recursive: true }, err => {

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 118 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead
if (err) return reject(err);

entryCount++;
Expand All @@ -127,18 +130,18 @@
const target = path.resolve(dir, header.linkname);
entryCount++;

fs.mkdir(dir, { recursive: true }, err => {

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 133 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead
if (err) return reject(err);

const relativeTarget = path.relative(dir, target);
fs.symlink(relativeTarget, destFilePath, err => {

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.symlink()' instead

Check warning on line 137 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.symlink()' instead
if (err) return reject(err);
successCount++;
stream.resume();
});
});
} else { // directory
fs.mkdir(destFilePath, { recursive: true }, err => {

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead

Check warning on line 144 in lib/utils.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.mkdir()' instead
if (err) return reject(err);
stream.resume();
});
Expand Down
2 changes: 1 addition & 1 deletion test/zip/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe('test/zip/index.test.js', () => {
fs.mkdirSync(destDir, { recursive: true });
await compressing.zip.uncompress(destFile, destDir);
const stat = fs.statSync(path.join(destDir, 'bin'));
assert(stat.mode === originStat.mode);
assert.equal(stat.mode, originStat.mode, 'file mode should be same after uncompress');
// console.log(destDir);
});
});
18 changes: 10 additions & 8 deletions test/zip/uncompress_stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,24 @@ describe('test/zip/uncompress_stream.test.js', () => {
pump(sourceStream, uncompressStream, err => {
assert(!err);
const res = dircompare.compareSync(originalDir, destDir);
assert(res.distinct === 0);
assert(res.equal === 5);
assert.equal(res.distinct, 0, 'distinct files count mismatch');
assert.equal(res.equal, 5, 'equal files count mismatch');
assert(res.totalFiles === 4);
assert(res.totalDirs === 1);
done();
});

uncompressStream.on('entry', (header, stream, next) => {
stream.on('end', next);

if (header.type === 'file') {
stream.pipe(fs.createWriteStream(path.join(destDir, header.name)));
pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name)))
.then(next)
.catch(done);
} else { // directory
fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => {
if (err) return done(err);
stream.resume();
});
stream.on('end', next);
}
});
});
Expand All @@ -231,15 +232,16 @@ describe('test/zip/uncompress_stream.test.js', () => {
});

uncompressStream.on('entry', (header, stream, next) => {
stream.on('end', next);

if (header.type === 'file') {
stream.pipe(fs.createWriteStream(path.join(destDir, header.name)));
pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name)))
.then(next)
.catch(done);
} else { // directory
fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => {
if (err) return done(err);
stream.resume();
});
stream.on('end', next);
}
});
});
Expand Down
Loading