Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 5ef15fe

Browse files
authored
Fix unzip on Windows (#161)
* Fix unzip on Windows * fix lint
1 parent f24edcd commit 5ef15fe

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

lib/modules.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { pipeline } from 'node:stream/promises'
77
import gunzip from 'gunzip-maybe'
88
import tar from 'tar-fs'
99
import unzip from 'unzip-stream'
10-
import { once } from 'node:events'
1110
import { createWriteStream } from 'node:fs'
1211
import { moduleBinaries } from './paths.js'
1312

@@ -79,23 +78,15 @@ export const installBinaryModule = async ({
7978
} else {
8079
await mkdir(join(moduleBinaries, module), { recursive: true })
8180
const parser = unzip.Parse()
82-
await Promise.all([
83-
(async () => {
84-
while (true) {
85-
const [entry] =
86-
/** @type {[UnzipStreamEntry]} */
87-
(await once(parser, 'entry'))
88-
const executableFileName = getExecutableFileName(executable)
89-
if (entry.path === executableFileName) {
90-
const outPath = join(moduleBinaries, module, executableFileName)
91-
await pipeline(entry, createWriteStream(outPath))
92-
await chmod(outPath, 0o755)
93-
return
94-
}
95-
}
96-
})(),
97-
pipeline(res.body, parser)
98-
])
81+
parser.on('entry', async entry => {
82+
const executableFileName = getExecutableFileName(executable)
83+
const outPath = join(moduleBinaries, module, entry.path)
84+
await pipeline(entry, createWriteStream(outPath))
85+
if (entry.path === executableFileName) {
86+
await chmod(outPath, 0o755)
87+
}
88+
})
89+
await pipeline(res.body, parser)
9990
}
10091
console.log(`[${module}] ✓ ${outFile}`)
10192
}

0 commit comments

Comments
 (0)