resolveDomainsRoots static method

Map<String, Directory> resolveDomainsRoots(
  1. List domains, [
  2. Directory? rootDir
])

Implementation

static Map<String, Directory> resolveDomainsRoots(
  List domains, [
  Directory? rootDir,
]) {
  var domainsRoots =
      domains
          .map((e) {
            var s = e.toString();
            var parts = s.split('=');

            var domain = parts[0];

            if (parts.length == 1) {
              return rootDir != null ? MapEntry(domain, rootDir) : null;
            } else {
              var path = parts[1].trim();
              var dir = path.isNotEmpty ? Directory(path) : rootDir;
              return dir != null ? MapEntry(domain, dir) : null;
            }
          })
          .nonNulls
          .toMapFromEntries();
  return domainsRoots;
}