(config: Config, selectedPlatformName?: string)
| 281 | } |
| 282 | |
| 283 | export 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 | |
| 311 | export async function getKnownPlatforms(): Promise<string[]> { |
| 312 | return ['web', 'android', 'ios']; |
no test coverage detected