How to use the @react-native-community/cli-tools.checkCommandExists function in @react-native-community/cli-tools

To help you get started, we’ve selected a few @react-native-community/cli-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-native-community / cli / packages / platform-android / src / commands / runAndroid / getAdbPath.ts View on Github external
function checkAdbPath() {
  const adbPath = getAdbPath();
  const adbPathExists = fs.existsSync(adbPath);
  const adbCmdExists = checkCommandExists('adb');
  const adbNotFoundError = `"adb" not found in $location$. APK installation $prediction$ fail. Make sure you installed the Android SDK correctly. Read more at ${chalk.underline.dim(
    'https://facebook.github.io/react-native/docs/getting-started',
  )}`;
  if (!adbPathExists || !adbCmdExists) {
    const notFoundLocation = `${
      !adbCmdExists ? 'PATH environment variable' : adbPath
    }`;
    logger.warn(
      adbNotFoundError
        .replace('$location$', notFoundLocation)
        .replace('$prediction$', 'might'),
    );
  } else if (!adbPathExists && !adbCmdExists) {
    throw new CLIError(
      adbNotFoundError
        .replace('$location$', `PATH environment variable or ${adbPath}`)