( config: Config, selectedPlatformName: string, deployment: boolean, inline = false, )
| 11 | * Sync is a copy and an update in one. |
| 12 | */ |
| 13 | export async function syncCommand( |
| 14 | config: Config, |
| 15 | selectedPlatformName: string, |
| 16 | deployment: boolean, |
| 17 | inline = false, |
| 18 | ): Promise<void> { |
| 19 | if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) { |
| 20 | try { |
| 21 | await copyCommand(config, selectedPlatformName, inline); |
| 22 | } catch (e: any) { |
| 23 | logger.error(e.stack ?? e); |
| 24 | } |
| 25 | await updateCommand(config, selectedPlatformName, deployment); |
| 26 | } else { |
| 27 | const then = +new Date(); |
| 28 | const platforms = await selectPlatforms(config, selectedPlatformName); |
| 29 | try { |
| 30 | await check([() => checkPackage(), () => checkWebDir(config), ...(await addUpdateChecks(config, platforms))]); |
| 31 | await allSerial(platforms.map((platformName) => () => sync(config, platformName, deployment, inline))); |
| 32 | const now = +new Date(); |
| 33 | const diff = (now - then) / 1000; |
| 34 | logger.info(`Sync finished in ${diff}s`); |
| 35 | } catch (e: any) { |
| 36 | if (!isFatal(e)) { |
| 37 | fatal(e.stack ?? e); |
| 38 | } |
| 39 | |
| 40 | throw e; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | export async function sync(config: Config, platformName: string, deployment: boolean, inline = false): Promise<void> { |
| 46 | await runHooks(config, platformName, config.app.rootDir, 'capacitor:sync:before'); |
no test coverage detected