device init: Avoid extra request when not providing the --fleet option

Change-type: patch
This commit is contained in:
Thodoris Greasidis 2023-05-23 11:34:16 +03:00
parent 2b58143164
commit 063e9d40f0

@ -124,21 +124,16 @@ export default class DeviceInitCmd extends Command {
const balena = getBalenaSdk();
// Get application and
const application = await getApplication(
balena,
options.fleet ||
(
await (await import('../../utils/patterns')).selectApplication()
).slug,
{
$select: ['id', 'slug'],
$expand: {
is_for__device_type: {
$select: 'slug',
const application = options.fleet
? await getApplication(balena, options.fleet, {
$select: ['id', 'slug'],
$expand: {
is_for__device_type: {
$select: 'slug',
},
},
},
},
);
})
: await (await import('../../utils/patterns')).selectApplication();
// Register new device
const deviceUuid = balena.models.device.generateUniqueKey();