findScript function

ScriptDef? findScript(
  1. Iterable<ScriptDef> scripts,
  2. String idOrName
)

The script of scripts that idOrName names: by id, else by name, a page script over a project one.

Implementation

ScriptDef? findScript(Iterable<ScriptDef> scripts, String idOrName) {
  ScriptDef? byName;
  for (final s in scripts) {
    if (s.id == idOrName) return s;
    if (s.name == idOrName && (byName == null || (byName.isProjectScope && !s.isProjectScope))) byName = s;
  }
  return byName;
}