Scripts.fromYaml constructor

Scripts.fromYaml(
  1. Map<Object?, Object?> yaml, {
  2. required String workspacePath,
})

Implementation

factory Scripts.fromYaml(
  Map<Object?, Object?> yaml, {
  required String workspacePath,
}) {
  final scripts = yaml.map<String, Script>((key, value) {
    final name = assertIsA<String>(value: key, key: 'scripts');

    if (value == null) {
      throw MelosConfigException('The script $name has no value');
    }

    final script = Script.fromYaml(
      value,
      name: name,
      workspacePath: workspacePath,
    );

    return MapEntry(name, script);
  });

  return Scripts(UnmodifiableMapView(scripts));
}