spawn

Process spawn(

  1. String command,
  2. List<String> args, {
  3. bool shell = false,
})

Spawn a child process.

command - The command to run. args - Arguments to pass to the command. shell - Whether to run the command in a shell.

Implementation

Process spawn(String command, List<String> args, {bool shell = false}) {
  final cp = _require('child_process'.toJS) as JSObject;
  final jsArgs = args.map((a) => a.toJS).toList().toJS;
  final options = _createObject();
  _setProperty(options, 'shell'.toJS, shell.toJS);
  final spawnFn = _getProperty(cp, 'spawn'.toJS);
  final result = _callApply(spawnFn, cp, [command.toJS, jsArgs, options].toJS);
  final jsProcess = _ChildProcess._(result as JSObject);
  return Process._(jsProcess);
}