hasExecutable static method

Future<bool> hasExecutable(
  1. String executable
)

Checks if an executable exists on PATH.

Implementation

static Future<bool> hasExecutable(String executable) async {
  try {
    final cmd = Platform.isWindows ? 'where' : 'which';
    final result = await Process.run(cmd, [executable]);
    return result.exitCode == 0;
  } catch (_) {
    return false;
  }
}