diff --git a/app/common/PackageUtil.ts b/app/common/PackageUtil.ts index 5e689dc5..2596e0cb 100644 --- a/app/common/PackageUtil.ts +++ b/app/common/PackageUtil.ts @@ -109,18 +109,17 @@ export async function extractPackageJSON(tarballBytes: Buffer): Promise name === 'package/package.json', - onentry: entry => { - let json = ''; - entry.on('data', data => { - json += data.toString(); - }); - entry.on('end', () => { - try { - resolve(JSON.parse(json)); - } catch (err) { - reject(new Error('Error parsing package.json')); - } - }); + onentry: async entry => { + let chunks: Buffer[] = []; + for await (let chunk of entry) { + chunks.push(chunk); + } + try { + const data = Buffer.concat(chunks); + return resolve(JSON.parse(data.toString())); + } catch (err) { + reject(new Error('Error parsing package.json')); + } }, })); });