diff --git a/lib/actions/build.js b/lib/actions/build.js index f2f03b35..344c7f6f 100644 --- a/lib/actions/build.js +++ b/lib/actions/build.js @@ -182,22 +182,9 @@ Examples: if (arch != null && deviceType != null) { return [undefined, arch, deviceType]; } else { - return Promise.join( - helpers.getApplication(application), - helpers.getArchAndDeviceType(application), - function( - app, - { arch: resolvedArch, device_type: resolvedDeviceType }, - ) { - // @ts-ignore extending the app object - app.arch = resolvedArch; - app.device_type = resolvedDeviceType; - return app; - }, - ).then(app => - // @ts-ignore using the extended prop - [app, app.arch, app.device_type], - ); + return helpers + .getAppWithArch(application) + .then(app => [app, app.arch, app.device_type]); } }) diff --git a/lib/actions/deploy.js b/lib/actions/deploy.js index 07098986..d1e1f25a 100644 --- a/lib/actions/deploy.js +++ b/lib/actions/deploy.js @@ -296,20 +296,8 @@ Examples: }); } }) - .then(() => - Promise.join( - helpers.getApplication(appName), - helpers.getArchAndDeviceType(appName), - function(app, { arch, device_type }) { - // @ts-ignore extending the app object - app.arch = arch; - app.device_type = device_type; - return app; - }, - ).then(app => [app, !!options.build, !options.nologupload]), - ) - - .then(function([app, shouldPerformBuild, shouldUploadLogs]) { + .then(() => helpers.getAppWithArch(appName)) + .then(function(app) { return Promise.join( dockerUtils.getDocker(options), dockerUtils.generateBuildOpts(options), @@ -319,8 +307,8 @@ Examples: app, appName, // may be prefixed by 'owner/', unlike app.app_name image, - shouldPerformBuild, - shouldUploadLogs, + shouldPerformBuild: !!options.build, + shouldUploadLogs: !options.nologupload, buildEmulated: !!options.emulated, buildOpts, convertEol: options.convertEol, diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts index 5a092954..995bb530 100644 --- a/lib/utils/helpers.ts +++ b/lib/utils/helpers.ts @@ -143,9 +143,9 @@ export async function osProgressHandler(step: InitializeEmitter) { }); } -export function getArchAndDeviceType( +export function getAppWithArch( applicationName: string, -): Bluebird<{ arch: string; device_type: string }> { +): Bluebird { return Bluebird.join( getApplication(applicationName), getBalenaSdk().models.config.getDeviceTypes(), @@ -158,12 +158,12 @@ export function getArchAndDeviceType( throw new Error('Could not read application information!'); } - return { device_type: app.device_type, arch: config.arch }; + return { ...app, arch: config.arch }; }, ); } -export function getApplication(applicationName: string) { +function getApplication(applicationName: string) { // Check for an app of the form `user/application`, and send // that off to a special handler (before importing any modules) const match = applicationName.split('/');