balena-cli/build/utils/streams.js
Tim Perry e584dc43f7 Gzip images when uploading in resin deploy
Change-Type: minor
Connects-To: #549
2017-06-15 12:01:22 +02:00

17 lines
578 B
JavaScript

// Generated by CoffeeScript 1.12.6
exports.buffer = function(stream, bufferFile) {
var Promise, fileWriteStream, fs;
Promise = require('bluebird');
fs = require('fs');
fileWriteStream = fs.createWriteStream(bufferFile);
return new Promise(function(resolve, reject) {
return stream.on('error', reject).on('end', resolve).pipe(fileWriteStream);
}).then(function() {
return new Promise(function(resolve, reject) {
return fs.createReadStream(bufferFile).on('open', function() {
return resolve(this);
}).on('error', reject);
});
});
};