connect static method
Connects to the current daemon instance.
If one is not running, a new daemon instance will be started.
Implementation
static Future<BuildDaemonClient> connect(
String workingDirectory,
List<String> daemonCommand, {
Serializers? serializersOverride,
void Function(ServerLog)? logHandler,
bool includeParentEnvironment = true,
Map<String, String>? environment,
BuildMode buildMode = BuildMode.Auto,
}) async {
logHandler ??= (_) {};
var daemonSerializers = serializersOverride ?? serializers;
var daemonArgs = daemonCommand.sublist(1)
..add('--$buildModeFlag=$buildMode');
var process = await Process.start(
daemonCommand.first,
daemonArgs,
mode: ProcessStartMode.detachedWithStdio,
workingDirectory: workingDirectory,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
);
await _handleDaemonStartup(process, logHandler);
return BuildDaemonClient._(
await _existingPort(workingDirectory), daemonSerializers, logHandler);
}