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

Function syncCommand

cli/src/tasks/sync.ts:13–43  ·  view source on GitHub ↗
(
  config: Config,
  selectedPlatformName: string,
  deployment: boolean,
  inline = false,
)

Source from the content-addressed store, hash-verified

11 * Sync is a copy and an update in one.
12 */
13export 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
45export async function sync(config: Config, platformName: string, deployment: boolean, inline = false): Promise<void> {
46 await runHooks(config, platformName, config.app.rootDir, 'capacitor:sync:before');

Callers 1

runProgramFunction · 0.85

Calls 14

isValidPlatformFunction · 0.90
copyCommandFunction · 0.90
updateCommandFunction · 0.90
selectPlatformsFunction · 0.90
checkFunction · 0.90
checkPackageFunction · 0.90
checkWebDirFunction · 0.90
addUpdateChecksFunction · 0.90
allSerialFunction · 0.90
isFatalFunction · 0.90
fatalFunction · 0.90
syncFunction · 0.85

Tested by

no test coverage detected