mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-10 15:02:39 +00:00
17 lines
581 B
JavaScript
17 lines
581 B
JavaScript
|
// Generated by CoffeeScript 1.12.6
|
||
|
exports.buffer = function(stream, bufferFile) {
|
||
|
var Promise, fileWriteStream, fs;
|
||
|
Promise = require('bluebird');
|
||
|
fs = require('mz/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);
|
||
|
});
|
||
|
});
|
||
|
};
|