@@ -165,12 +165,11 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
165165 const fileParent = path . dirname ( file )
166166 if ( fileParent !== nodeModuleDir && ! autoUnpackDirs . has ( fileParent ) ) {
167167 autoUnpackDirs . add ( fileParent )
168-
168+ createDirPromises . push ( ensureDir ( path . join ( unpackedDest , path . relative ( src , fileParent ) ) ) )
169169 if ( createDirPromises . length > MAX_FILE_REQUESTS ) {
170170 await BluebirdPromise . all ( createDirPromises )
171171 createDirPromises . length = 0
172172 }
173- createDirPromises . push ( ensureDir ( path . join ( unpackedDest , path . relative ( src , fileParent ) ) ) )
174173 }
175174 continue
176175 }
@@ -189,13 +188,21 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
189188 }
190189
191190 log ( `${ path . relative ( src , nodeModuleDir ) } is not packed into asar archive - contains executable code` )
192- autoUnpackDirs . add ( nodeModuleDir )
193- const fileParent = path . dirname ( file )
194- if ( fileParent !== nodeModuleDir ) {
191+
192+ let fileParent = path . dirname ( file )
193+
194+ // create parent dir to be able to copy file later without directory existence check
195+ createDirPromises . push ( ensureDir ( path . join ( unpackedDest , path . relative ( src , fileParent ) ) ) )
196+ if ( createDirPromises . length > MAX_FILE_REQUESTS ) {
197+ await BluebirdPromise . all ( createDirPromises )
198+ createDirPromises . length = 0
199+ }
200+
201+ while ( fileParent !== nodeModuleDir ) {
195202 autoUnpackDirs . add ( fileParent )
196- // create parent dir to be able to copy file later without directory existence check
197- createDirPromises . push ( ensureDir ( path . join ( unpackedDest , path . relative ( src , fileParent ) ) ) )
203+ fileParent = path . dirname ( fileParent )
198204 }
205+ autoUnpackDirs . add ( nodeModuleDir )
199206 }
200207
201208 if ( readPackageJsonPromises . length > 0 ) {
0 commit comments