stream.on('data', (chunk) => buffers.push(chunk)); stream.on('end', () => { files[header.name] = Buffer.concat(buffers); cb(); });
stream.on('data', data => { buffers.push(data); }); stream.on('end', () => { files[header.name] = Buffer.concat(buffers); return cb(); });
extract.on('entry', (header, stream, cb) => { const file = header.name.split('/').pop() stream.on('data', (chunk) => { if (file === 'package.json') data += chunk }) stream.on('end', () => { if (data) { try { const pkgJSON = JSON.parse(data) resolve({ type: 'remote', version: pkgJSON.version, dependencies: pkgJSON.dependencies, url: spec }) } catch (e) { reject(e) } } else { cb() } }) stream.resume() })
/** * Find the list of file names in the specified chaincode deployment specification. * @private * @param {ChaincodeDeploymentSpec} chaincodeDeploymentSpec The chaincode deployment specification. * @returns {string[]} The list of file names. */ static async _findFileNames(chaincodeDeploymentSpec) { const codePackage = chaincodeDeploymentSpec.getCodePackage().toBuffer(); const gunzip = zlib.createGunzip(); const extract = tar.extract(); return new Promise((resolve) => { const fileNames = []; extract.on('entry', (header, stream, next) => { logger.debug('Package._findFileNames - found entry %s', header.name); fileNames.push(header.name); stream.on('end', () => { next(); }); stream.resume(); }); extract.on('finish', () => { resolve(fileNames.sort()); }); gunzip.pipe(extract); gunzip.end(codePackage); }); }
let content = ''; extract.on('entry', (header, stream, next) => { if (header.name === 'skeleton') { stream.on('data', data => { content += data.toString();
/** * Find the list of file names in the specified chaincode deployment specification. * @private * @param {ChaincodeDeploymentSpec} chaincodeDeploymentSpec The chaincode deployment specification. * @returns {string[]} The list of file names. */ static async _findFileNames(chaincodeDeploymentSpec) { const codePackage = chaincodeDeploymentSpec.getCodePackage().toBuffer(); const gunzip = zlib.createGunzip(); const extract = tar.extract(); return new Promise((resolve) => { const fileNames = []; extract.on('entry', (header, stream, next) => { logger.debug('Package._findFileNames - found entry %s', header.name); fileNames.push(header.name); stream.on('end', () => { next(); }); stream.resume(); }); extract.on('finish', () => { resolve(fileNames.sort()); }); gunzip.pipe(extract); gunzip.end(codePackage); }); }