resolveExecutable static method

String resolveExecutable(
  1. String name
)

Implementation

static String resolveExecutable(String name) {
  if (!Platform.isWindows) return name;

  final exts = ['.exe', '.bat', '.cmd'];
  for (final ext in exts) {
    final full = '$name$ext';
    final result = Process.runSync('where', [full]);
    if (result.exitCode == 0) {
      return result.stdout.toString().split('\n').first.trim();
    }
  }

  return name;
}