File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ export default class MakerAppImage extends MakerBase<MakerAppImageConfig> {
348
348
setChecksum(runtime, await readFile(outFile)) :
349
349
runtime
350
350
)*/
351
- . then ( runtime => joinFiles ( Buffer . from ( runtime ) , outFile ) )
351
+ . then ( runtime => joinFiles ( runtime , outFile ) )
352
352
. then ( buffer => writeFile ( outFile , buffer ) )
353
353
. then ( ( ) => chmod ( outFile , 0o755 ) )
354
354
// Finally, return a path to maker artifacts
Original file line number Diff line number Diff line change @@ -256,17 +256,25 @@ export function getSquashFsVer() {
256
256
/**
257
257
* Concatenates files and/or buffers into a new buffer.
258
258
*/
259
- export async function joinFiles ( ...filesAndBuffers :( string | Buffer ) [ ] ) {
259
+ export async function joinFiles ( ...filesAndBuffers :( string | ArrayBufferLike | Uint8Array ) [ ] ) {
260
260
const { readFile} = await import ( "fs/promises" ) ;
261
- const bufferArray : Promise < Buffer > [ ] = [ ] ;
261
+ const bufferArray : Promise < Uint8Array > [ ] = [ ] ;
262
262
for ( const path of filesAndBuffers )
263
- if ( Buffer . isBuffer ( path ) )
264
- bufferArray . push ( Promise . resolve ( path ) ) ;
265
- else if ( existsSync ( path ) )
263
+ if ( path instanceof < Uint8ArrayConstructor > Object . getPrototypeOf ( Uint8Array ) )
264
+ bufferArray . push ( Promise . resolve ( new Uint8Array ( path . buffer ) ) ) ;
265
+ else if ( path instanceof ArrayBuffer || path instanceof SharedArrayBuffer )
266
+ bufferArray . push ( Promise . resolve ( new Uint8Array ( path ) ) ) ;
267
+ else if ( existsSync ( path ) )
266
268
bufferArray . push ( readFile ( path ) ) ;
267
269
else
268
270
throw new Error ( `Unable to concat '${ path } ': Invalid path.` ) ;
269
- return Promise . all ( bufferArray ) . then ( array => Buffer . concat ( array ) )
271
+ return Promise . all ( bufferArray )
272
+ . then ( array => new Uint8Array (
273
+ new Array < number > ( ) . concat (
274
+ ...array . map ( v => [ ...v ] )
275
+ )
276
+ )
277
+ )
270
278
}
271
279
272
280
/**
You can’t perform that action at this time.
0 commit comments