Fix TypeError when running 'balena apps'

Change-type: patch
Signed-off-by: Paulo Castro <paulo@balena.io>
This commit is contained in:
Paulo Castro 2019-05-20 16:52:48 +01:00
parent 3b5f3c6665
commit d47fe0609f

View File

@ -82,6 +82,7 @@ exports.list =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
_ = require('lodash')
balena = require('balena-sdk').fromSharedOptions() balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals') visuals = require('resin-cli-visuals')
@ -94,8 +95,8 @@ exports.list =
$expand: owns__device: $select: 'is_online' $expand: owns__device: $select: 'is_online'
.then (applications) -> .then (applications) ->
applications.forEach (application) -> applications.forEach (application) ->
application.device_count = application.owns__device.length application.device_count = _.size(application.owns__device)
application.online_devices = application.owns__device.filter((d) -> d.is_online == true).length application.online_devices = _.filter(application.owns__device, (d) -> d.is_online == true).length
console.log visuals.table.horizontal applications, [ console.log visuals.table.horizontal applications, [
'id' 'id'