mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-30 08:03:55 +00:00
Merge pull request #144 from resin-io/jviotti/refactor/note
Refactor note set command to use promises
This commit is contained in:
commit
ee286c5690
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, resin;
|
||||
var Promise, _, resin;
|
||||
|
||||
Promise = require('bluebird');
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
@ -20,10 +22,12 @@
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
if (_.isEmpty(params.note)) {
|
||||
return done(new Error('Missing note content'));
|
||||
}
|
||||
return resin.models.device.note(options.device, params.note).nodeify(done);
|
||||
return Promise["try"](function() {
|
||||
if (_.isEmpty(params.note)) {
|
||||
throw new Error('Missing note content');
|
||||
}
|
||||
return resin.models.device.note(options.device, params.note);
|
||||
}).nodeify(done);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
Promise = require('bluebird')
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk')
|
||||
|
||||
@ -25,8 +26,9 @@ exports.set =
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
Promise.try ->
|
||||
if _.isEmpty(params.note)
|
||||
throw new Error('Missing note content')
|
||||
|
||||
if _.isEmpty(params.note)
|
||||
return done(new Error('Missing note content'))
|
||||
|
||||
resin.models.device.note(options.device, params.note).nodeify(done)
|
||||
resin.models.device.note(options.device, params.note)
|
||||
.nodeify(done)
|
||||
|
Loading…
x
Reference in New Issue
Block a user