(config: Config, selectedPlatformName: string, deployment: boolean)
| 19 | import { allSerial } from '../util/promise'; |
| 20 | |
| 21 | export async function updateCommand(config: Config, selectedPlatformName: string, deployment: boolean): Promise<void> { |
| 22 | if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) { |
| 23 | const platformDir = resolvePlatform(config, selectedPlatformName); |
| 24 | if (platformDir) { |
| 25 | await runPlatformHook(config, selectedPlatformName, platformDir, 'capacitor:update'); |
| 26 | } else { |
| 27 | logger.error(`Platform ${c.input(selectedPlatformName)} not found.`); |
| 28 | } |
| 29 | } else { |
| 30 | const then = +new Date(); |
| 31 | const platforms = await selectPlatforms(config, selectedPlatformName); |
| 32 | try { |
| 33 | await check([() => checkPackage(), ...(await addUpdateChecks(config, platforms))]); |
| 34 | await allSerial(platforms.map((platformName) => async () => await update(config, platformName, deployment))); |
| 35 | const now = +new Date(); |
| 36 | const diff = (now - then) / 1000; |
| 37 | logger.info(`Update finished in ${diff}s`); |
| 38 | } catch (e: any) { |
| 39 | if (!isFatal(e)) { |
| 40 | fatal(e.stack ?? e); |
| 41 | } |
| 42 | |
| 43 | throw e; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | export async function addUpdateChecks(config: Config, platforms: string[]): Promise<CheckFunction[]> { |
| 49 | let checks: CheckFunction[] = []; |
no test coverage detected