Merge pull request #246 from resin-io/jviotti/refactor/rindle

Use rindle instead of custom waitStream
This commit is contained in:
Juan Cruz Viotti 2015-10-21 11:15:12 -04:00
commit 5498e45a35
5 changed files with 9 additions and 19 deletions

View File

@ -1,5 +1,5 @@
(function() {
var Promise, _, commandOptions, form, fs, helpers, init, manager, patterns, resin, stepHandler, umount, unzip, visuals;
var Promise, _, commandOptions, form, fs, helpers, init, manager, patterns, resin, rindle, stepHandler, umount, unzip, visuals;
fs = require('fs');
@ -11,6 +11,8 @@
unzip = require('unzip2');
rindle = require('rindle');
resin = require('resin-sdk');
manager = require('resin-image-manager');
@ -64,7 +66,7 @@
} else {
output = fs.createWriteStream(options.output);
}
return helpers.waitStream(stream.pipe(output))["return"](options.output);
return rindle.wait(stream.pipe(output))["return"](options.output);
}).tap(function(output) {
return console.info("The image was downloaded to " + output);
}).nodeify(done);
@ -83,7 +85,7 @@
});
bar = new visuals.Progress('Writing Device OS');
step.on('burn', _.bind(bar.update, bar));
return helpers.waitStream(step);
return rindle.wait(step);
};
exports.configure = {

View File

@ -46,14 +46,6 @@
}
};
exports.waitStream = function(stream) {
return new Promise(function(resolve, reject) {
stream.on('close', resolve);
stream.on('end', resolve);
return stream.on('error', reject);
});
};
exports.sudo = function(command) {
var spawn;
if (os.platform() === 'win32') {

View File

@ -3,6 +3,7 @@ _ = require('lodash')
Promise = require('bluebird')
umount = Promise.promisifyAll(require('umount'))
unzip = require('unzip2')
rindle = require('rindle')
resin = require('resin-sdk')
manager = require('resin-image-manager')
visuals = require('resin-cli-visuals')
@ -54,7 +55,7 @@ exports.download =
else
output = fs.createWriteStream(options.output)
return helpers.waitStream(stream.pipe(output)).return(options.output)
return rindle.wait(stream.pipe(output)).return(options.output)
.tap (output) ->
console.info("The image was downloaded to #{output}")
.nodeify(done)
@ -71,7 +72,7 @@ stepHandler = (step) ->
step.on('burn', _.bind(bar.update, bar))
return helpers.waitStream(step)
return rindle.wait(step)
exports.configure =
signature: 'os configure <image> <uuid>'

View File

@ -33,12 +33,6 @@ exports.stateToString = (state) ->
else
throw new Error("Unsupported operation: #{state.operation.type}")
exports.waitStream = (stream) ->
return new Promise (resolve, reject) ->
stream.on('close', resolve)
stream.on('end', resolve)
stream.on('error', reject)
exports.sudo = (command) ->
# Bypass privilege elevation for Windows for now.

View File

@ -60,6 +60,7 @@
"resin-settings-client": "^3.1.0",
"resin-vcs": "^2.0.0",
"rimraf": "^2.4.3",
"rindle": "^1.0.0",
"tmp": "0.0.28",
"umount": "^1.1.1",
"underscore.string": "^3.1.1",