| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b2d231b commit 5f281d9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -193,23 +193,24 @@ describe('test/zip/uncompress_stream.test.js', () => { | |||
| 193 | 193 | pump(sourceStream, uncompressStream, err => { | |
| 194 | 194 | assert(!err); | |
| 195 | 195 | const res = dircompare.compareSync(originalDir, destDir); | |
| 196 | - assert(res.distinct === 0); | ||
| 197 | - assert(res.equal === 5); | ||
| 196 | + assert.equal(res.distinct, 0, 'distinct files count mismatch'); | ||
| 197 | + assert.equal(res.equal, 5, 'equal files count mismatch'); | ||
| 198 | 198 | assert(res.totalFiles === 4); | |
| 199 | 199 | assert(res.totalDirs === 1); | |
| 200 | 200 | done(); | |
| 201 | 201 | }); | |
| 202 | 202 | ||
| 203 | 203 | uncompressStream.on('entry', (header, stream, next) => { | |
| 204 | - stream.on('end', next); | ||
| 205 | - | ||
| 206 | 204 | if (header.type === 'file') { | |
| 207 | - stream.pipe(fs.createWriteStream(path.join(destDir, header.name))); | ||
| 205 | + pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name))) | ||
| 206 | + .then(next) | ||
| 207 | + .catch(done); | ||
| 208 | 208 | } else { // directory | |
| 209 | 209 | fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => { | |
| 210 | 210 | if (err) return done(err); | |
| 211 | 211 | stream.resume(); | |
| 212 | 212 | }); | |
| 213 | + stream.on('end', next); | ||
| 213 | 214 | } | |
| 214 | 215 | }); | |
| 215 | 216 | }); | |
@@ -231,15 +232,16 @@ describe('test/zip/uncompress_stream.test.js', () => { | |||
| 231 | 232 | }); | |
| 232 | 233 | ||
| 233 | 234 | uncompressStream.on('entry', (header, stream, next) => { | |
| 234 | - stream.on('end', next); | ||
| 235 | - | ||
| 236 | 235 | if (header.type === 'file') { | |
| 237 | - stream.pipe(fs.createWriteStream(path.join(destDir, header.name))); | ||
| 236 | + pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name))) | ||
| 237 | + .then(next) | ||
| 238 | + .catch(done); | ||
| 238 | 239 | } else { // directory | |
| 239 | 240 | fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => { | |
| 240 | 241 | if (err) return done(err); | |
| 241 | 242 | stream.resume(); | |
| 242 | 243 | }); | |
| 244 | + stream.on('end', next); | ||
| 243 | 245 | } | |
| 244 | 246 | }); | |
| 245 | 247 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments