resolveServerScriptFor function

String resolveServerScriptFor({
  1. required String executableDir,
})

The resolution proper, with the one unmockable input passed in.

executableDir only names the location reported when nothing is found; the packaged layout is never run from (see resolveDefaultServerScript).

Implementation

String resolveServerScriptFor({required String executableDir}) {
  final candidates = agentSdkServerScriptCandidates(
    executableDir: executableDir,
  );
  for (final candidate in candidates) {
    if (File(candidate).existsSync()) return candidate;
  }
  // Nothing found: a concrete location rather than an empty string, so the
  // error message names somewhere.
  final sep = Platform.pathSeparator;
  return '$executableDir$sep$agentSdkServerPayloadDir$sep'
      '$agentSdkServerScriptName';
}