balena-cli/lib/resin/device/device.coffee

21 lines
516 B
CoffeeScript
Raw Normal View History

_ = require('lodash')
2014-11-26 17:12:39 +00:00
# TODO: This should be fetch from the server
DEVICES = require('./device-data.json')
exports.getDisplayName = (device) ->
if _.indexOf(exports.getSupportedDevices(), device) isnt -1
return device
for key, value of DEVICES
if _.indexOf(value.names, device) isnt -1
return key
return 'Unknown'
2014-11-24 12:25:45 +00:00
exports.getDeviceSlug = (device) ->
displayName = exports.getDisplayName(device)
return DEVICES[displayName]?.slug or 'unknown'
2014-11-24 12:25:45 +00:00
exports.getSupportedDevices = ->
return _.keys(DEVICES)