combine method

EnvConfig? combine({
  1. required String directory,
})

Implementation

EnvConfig? combine({required String directory}) {
  final commands = <String>{};
  final files = <String>{};

  for (final config in this) {
    if (config == null) continue;

    for (var command in config.commands ?? <String>[]) {
      while (command.startsWith(Identifiers.concurrent)) {
        command = command.substring(Identifiers.concurrent.length);
      }

      commands.add(command);
    }

    files.addAll(config.files ?? []);
  }

  if (commands.isEmpty && files.isEmpty) return null;

  return EnvConfig(
    commands: commands,
    files: files,
    workingDirectory: directory,
  );
}