entries static method

List<String> entries(
  1. Iterable<String> targets
)

Expands targets (files or directories) into entry files. Directories are searched recursively for main.tl|lua and *_test.tl|lua.

Implementation

static List<String> entries(Iterable<String> targets) {
  final found = <String>[];
  for (final target in targets) {
    final type = FileSystemEntity.typeSync(target);
    if (type == FileSystemEntityType.file) {
      found.add(p.normalize(p.absolute(target)));
    } else if (type == FileSystemEntityType.directory) {
      final files =
          Directory(target)
              .listSync(recursive: true)
              .whereType<File>()
              .map((file) => p.normalize(p.absolute(file.path)))
              .where(isLuaEntry)
              .toList()
            ..sort();
      found.addAll(files);
    } else {
      throw ArgumentError.value(
        target,
        'target',
        'No such file or directory',
      );
    }
  }
  return found;
}