balena-cli/lib/helpers/helpers.coffee
2014-12-09 12:03:12 -04:00

17 lines
519 B
CoffeeScript

url = require('url')
_ = require('lodash')
resin = require('../resin')
# TODO: Use _.chop from underscore.string
exports.formatLongString = (string, n) ->
return string if not n?
splitRegexp = new RegExp(".{1,#{n}}", 'g')
splittedString = string.match(splitRegexp)
return splittedString.join('\n')
exports.isDeviceUUIDValid = (uuid, callback) ->
resin.models.device.getAll (error, devices) ->
return callback?(error) if error?
uuidExists = _.findWhere(devices, { uuid })?
return callback(null, uuidExists)