load static method

NodeProfile load({
  1. String? path,
  2. String? home,
  3. Map<String, String>? environment,
})

Loads the profile from path (defaults to defaultPath).

A missing file yields empty. Throws FormatException when the file is not valid YAML or env is present but not a mapping. environment overrides the variables used for ${VAR} expansion (tests).

Implementation

static NodeProfile load({
  String? path,
  String? home,
  Map<String, String>? environment,
}) {
  final file = File(path ?? defaultPath(home: home));
  if (!file.existsSync()) return empty;
  final raw = _parse(file.readAsStringSync(), file.path);
  return NodeProfile(expand(raw, environment ?? Platform.environment));
}