buildExecCommand function

({List<String> args, String executable}) buildExecCommand(
  1. String command,
  2. ShellConfig config, {
  3. String? workingDirectory,
  4. bool trackCwd = false,
})

Build the command and arguments for shell execution.

Implementation

({String executable, List<String> args}) buildExecCommand(
  String command,
  ShellConfig config, {
  String? workingDirectory,
  bool trackCwd = false,
}) {
  switch (config.type) {
    case ShellType.bash:
    case ShellType.zsh:
    case ShellType.sh:
    case ShellType.fish:
      final args = ['-c', command];
      return (executable: config.shellPath, args: args);

    case ShellType.powershell:
      return (
        executable: config.shellPath,
        args: ['-NoProfile', '-NonInteractive', '-Command', command],
      );

    case ShellType.cmd:
      return (executable: config.shellPath, args: ['/c', command]);
  }
}