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

Function selectPlatforms

cli/src/common.ts:283–309  ·  view source on GitHub ↗
(config: Config, selectedPlatformName?: string)

Source from the content-addressed store, hash-verified

281}
282
283export async function selectPlatforms(config: Config, selectedPlatformName?: string): Promise<string[]> {
284 if (selectedPlatformName) {
285 // already passed in a platform name
286 const platformName = selectedPlatformName.toLowerCase().trim();
287
288 if (!(await isValidPlatform(platformName))) {
289 fatal(`Invalid platform: ${c.input(platformName)}`);
290 } else if (!(await getProjectPlatformDirectory(config, platformName))) {
291 if (platformName === 'web') {
292 fatal(`Could not find the web platform directory.\n` + `Make sure ${c.strong(config.app.webDir)} exists.`);
293 }
294 fatal(
295 `${c.strong(platformName)} platform has not been added yet.\n` +
296 `See the docs for adding the ${c.strong(platformName)} platform: ${c.strong(
297 `https://capacitorjs.com/docs/${platformName}#adding-the-${platformName}-platform`,
298 )}`,
299 );
300 }
301
302 // return the platform in an string array
303 return [platformName];
304 }
305
306 // wasn't given a platform name, so let's
307 // get the platforms that have already been created
308 return getAddedPlatforms(config);
309}
310
311export async function getKnownPlatforms(): Promise<string[]> {
312 return ['web', 'android', 'ios'];

Callers 8

doctorCommandFunction · 0.90
listCommandFunction · 0.90
copyCommandFunction · 0.90
updateCommandFunction · 0.90
runCommandFunction · 0.90
syncCommandFunction · 0.90
openCommandFunction · 0.90
buildCommandFunction · 0.90

Calls 4

fatalFunction · 0.90
isValidPlatformFunction · 0.85
getAddedPlatformsFunction · 0.85

Tested by

no test coverage detected