Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit e6dceda

Browse files
cleanup
1 parent 0731f45 commit e6dceda

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/tar-stream-to-objects.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,29 @@ module.exports = (err, res, send, done) => {
1010
return done(err)
1111
}
1212

13-
const ex = tar.extract()
14-
res.pipe(ex)
15-
1613
const objStream = new Readable({ objectMode: true })
1714
objStream._read = function noop () {}
1815

19-
ex.on('entry', (header, stream, next) => {
20-
stream.on('end', next)
21-
22-
if (header.type !== 'directory') {
23-
objStream.push({
24-
path: header.name,
25-
content: stream
26-
})
27-
} else {
28-
objStream.push({
29-
path: header.name
30-
})
31-
stream.resume()
32-
}
33-
})
34-
35-
ex.on('finish', () => {
36-
objStream.push(null)
37-
})
16+
res
17+
.pipe(tar.extract())
18+
.on('entry', (header, stream, next) => {
19+
stream.on('end', next)
20+
21+
if (header.type !== 'directory') {
22+
objStream.push({
23+
path: header.name,
24+
content: stream
25+
})
26+
} else {
27+
objStream.push({
28+
path: header.name
29+
})
30+
stream.resume()
31+
}
32+
})
33+
.on('finish', () => {
34+
objStream.push(null)
35+
})
3836

3937
done(null, objStream)
4038
}

0 commit comments

Comments
 (0)