# All files / src/platformTools target.js

53.16% Statements 42/79
20.37% Branches 11/54
26.67% Functions 4/15
75.76% Lines 25/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    932x
    2x
    2x
    2x
    2x

    2x
    2x
    2x
    2x
    2x
    2x
    2x

    3x
    1x

    1x
    1x

    2x

    4x
    1x

    1x

    1x

    1x

    1x

    1x

    2x

     /* eslint-disable import/no-cycle */
    import chalk from 'chalk';
    import path from 'path';
    import inquirer from 'inquirer';
    import {
        isPlatformSupportedSync, getConfig, logTask, logComplete, logError,
        getAppFolder, isPlatformSupported, checkSdk
    } from '../common';
    import PlatformSetup from '../setupTools';
    import { IOS, ANDROID, TVOS, TIZEN, WEBOS, ANDROID_TV, ANDROID_WEAR, KAIOS, CLI_ANDROID_ADB, CLI_ANDROID_AVDMANAGER, CLI_ANDROID_EMULATOR, CLI_ANDROID_SDKMANAGER } from '../constants';
    import { launchTizenSimulator } from './tizen';
    import { launchWebOSimulator, listWebOSTargets } from './webos';
    import { listAndroidTargets, launchAndroidSimulator } from './android/deviceManager';
    import { listAppleDevices, launchAppleSimulator } from './apple';
    import { launchKaiOSSimulator } from './firefox';

    export const rnvTargetLaunch = async (c) => {
        logTask('_runLaunch');

        await isPlatformSupported(c);

        const { platform, program } = c;
        const target = program.target || c.files.workspace.config.defaultTargets[platform];

        switch (platform) {
        case ANDROID:
        case ANDROID_TV:
        case ANDROID_WEAR:
            launchAndroidSimulator(c, platform, target)
                .then(() => resolve())
                .catch(e => reject(e));
            return;
        case IOS:
        case TVOS:
            launchAppleSimulator(c, platform, target)
                .then(() => resolve())
                .catch(e => reject(e));
            return;
        case TIZEN:
            launchTizenSimulator(c, target)
                .then(() => resolve())
                .catch(e => reject(e));
            return;
        case WEBOS:
            launchWebOSimulator(c, target)
                .then(() => resolve())
                .catch(e => reject(e));
            return;
        case KAIOS:
            launchKaiOSSimulator(c, target)
                .then(() => resolve())
                .catch(e => reject(e));
            return;
        default:
            return Promise.reject(
                `"target launch" command does not support ${chalk.white.bold(
                    platform
                )} platform yet. You will have to launch the emulator manually. Working on it!`
            );
        }
    };

    export const rnvTargetList = async (c) => {
        logTask('rnvTargetList');

        await isPlatformSupported(c);

        const { platform } = c;

        const throwError = (err) => {
            throw err;
        };

        switch (platform) {
        case ANDROID:
        case ANDROID_TV:
        case ANDROID_WEAR:
            if (!checkSdk(c, platform, logError)) {
                const setupInstance = PlatformSetup(c);
                await setupInstance.askToInstallSDK('android');
            }
            return listAndroidTargets(c, platform);
        case IOS:
        case TVOS:
            return listAppleDevices(c, platform);
        case WEBOS:I
            if (!checkSdk(c, platform, throwError)) return;
            return listWebOSTargets(c);
        default:
            return Promise.reject(`"target list" command does not support ${chalk.white.bold(platform)} platform yet. Working on it!`);
        }
    };