balena-cli/lib/actions/notes.coffee

22 lines
552 B
CoffeeScript
Raw Normal View History

2014-12-24 16:40:40 +00:00
async = require('async')
permissions = require('../permissions/permissions')
errors = require('../errors/errors')
helpers = require('../helpers/helpers')
2015-01-08 12:04:37 +00:00
resin = require('resin-sdk')
2014-12-24 16:40:40 +00:00
exports.set = permissions.user (params, options) ->
if not options.device?
errors.handle(new Error('You have to specify a device'))
async.waterfall([
(callback) ->
if not params.note?
helpers.readStdin(callback)
return callback(null, params.note)
(note, callback) ->
resin.models.device.note(options.device, note, callback)
], errors.handle)