buildEnvVarsExtra function

Map<String, String> buildEnvVarsExtra([
  1. EnvVarsExtraOptions options = const EnvVarsExtraOptions()
])

Returns the synthetic Env keys (OS / ARCH / DART_VERSION) plus runner version and retry keys when supplied.

Implementation

Map<String, String> buildEnvVarsExtra([
  EnvVarsExtraOptions options = const EnvVarsExtraOptions(),
]) {
  final out = <String, String>{
    'OS': osLabel(),
    'ARCH': archLabel(),
    'DART_VERSION': dartVersion(),
  };
  final versionKey = options.versionKey;
  final version = options.version;
  if (versionKey != null &&
      versionKey.isNotEmpty &&
      version != null &&
      version.isNotEmpty) {
    out[versionKey] = version;
  }
  final retryKey = options.retryKey;
  if (retryKey != null && retryKey.isNotEmpty && options.retry > 0) {
    out[retryKey] = options.retry.toString();
  }
  options.extra?.forEach((key, value) => out[key] = value);
  return out;
}