MCPcopy
hub / github.com/ionic-team/capacitor / updateCommand

Function updateCommand

cli/src/tasks/update.ts:21–46  ·  view source on GitHub ↗
(config: Config, selectedPlatformName: string, deployment: boolean)

Source from the content-addressed store, hash-verified

19import { allSerial } from '../util/promise';
20
21export 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
48export async function addUpdateChecks(config: Config, platforms: string[]): Promise<CheckFunction[]> {
49 let checks: CheckFunction[] = [];

Callers 2

syncCommandFunction · 0.90
runProgramFunction · 0.85

Calls 13

isValidPlatformFunction · 0.90
resolvePlatformFunction · 0.90
runPlatformHookFunction · 0.90
selectPlatformsFunction · 0.90
checkFunction · 0.90
checkPackageFunction · 0.90
allSerialFunction · 0.90
isFatalFunction · 0.90
fatalFunction · 0.90
addUpdateChecksFunction · 0.85
updateFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected