mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-07 11:26:41 +00:00
Document resin/device
This commit is contained in:
parent
8c774bace2
commit
98e845a90b
@ -3,6 +3,17 @@ _ = require('lodash')
|
||||
# TODO: This should be fetch from the server
|
||||
DEVICES = require('./device-data.json')
|
||||
|
||||
# Get display name for a device
|
||||
#
|
||||
# For a list of supported devices, see getSupportedDevices()
|
||||
#
|
||||
# @param {String} device device name
|
||||
# @return {String} device display name or 'Unknown'
|
||||
#
|
||||
# @example Get display name
|
||||
# console.log resin.device.getDisplayName('raspberry-pi') # Raspberry Pi
|
||||
# console.log resin.device.getDisplayName('rpi') # Raspberry Pi
|
||||
#
|
||||
exports.getDisplayName = (device) ->
|
||||
if _.indexOf(exports.getSupportedDevices(), device) isnt -1
|
||||
return device
|
||||
@ -12,9 +23,25 @@ exports.getDisplayName = (device) ->
|
||||
return key
|
||||
return 'Unknown'
|
||||
|
||||
# Get device slug
|
||||
#
|
||||
# @param {String} device device name
|
||||
# @return {String} device slug or 'unknown'
|
||||
#
|
||||
# @example Get device slug
|
||||
# console.log resin.device.getDeviceSlug('Raspberry Pi') # raspberry-pi
|
||||
#
|
||||
exports.getDeviceSlug = (device) ->
|
||||
displayName = exports.getDisplayName(device)
|
||||
return DEVICES[displayName]?.slug or 'unknown'
|
||||
|
||||
# Get a list of supported devices
|
||||
#
|
||||
# @return {Array<String>} a list of all supported devices, by their display names
|
||||
#
|
||||
# @example Get all supported devices
|
||||
# devices = resin.device.getSupportedDevices()
|
||||
# console.log(devices)
|
||||
#
|
||||
exports.getSupportedDevices = ->
|
||||
return _.keys(DEVICES)
|
||||
|
Loading…
x
Reference in New Issue
Block a user