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

View File

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