diff --git a/lib/install.js b/lib/install.js index 8af0caca..45b1b199 100644 --- a/lib/install.js +++ b/lib/install.js @@ -143,13 +143,14 @@ function place_binary(uri, targetDir, opts, callback) { log.info('install', `unpacking ${entry.path}`); }; + // resolve on extract close, not source end, so files are fully written before the caller loads them dataStream.pipe(extract(targetDir, countExtractions)) .on('error', (e) => { reject(e); + }) + .on('close', () => { + resolve(`extracted file count: ${extractions}`); }); - dataStream.on('end', () => { - resolve(`extracted file count: ${extractions}`); - }); dataStream.on('error', (e) => { reject(e); });