ensureInstalled function

Future<void> ensureInstalled(
  1. String processName, {
  2. List<String>? installCommands,
})

Implementation

Future<void> ensureInstalled(
  String processName, {
  List<String>? installCommands,
}) async {
  if (!await isInstalled(processName)) {
    await _updateDefaultPackageManager();
    installCommands ??= _defaultInstallCommands;
    installCommands.add(processName);
    final executable = installCommands.first;
    await runProcess(
      printCall: true,
      executable,
      installCommands.length > 1 ? installCommands.sublist(1) : [],
      runInShell: true,
    );
  }
}