@@ -7,7 +7,6 @@ import { pipeline } from 'node:stream/promises'
77import gunzip from 'gunzip-maybe'
88import tar from 'tar-fs'
99import unzip from 'unzip-stream'
10- import { once } from 'node:events'
1110import { createWriteStream } from 'node:fs'
1211import { 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