Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 5f20165

Browse files
committed
refactor(template_cache_generator): minor change: extract function
1 parent 7419e55 commit 5f20165

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/tools/template_cache_generator.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,16 @@ class TemplateCollectingVisitor {
292292
}
293293
}
294294

295+
String _resolveInTemplateRoots(String uri, List<String> templateRoots) {
296+
var paths = templateRoots.map((r) => '$r/$uri');
297+
return paths.firstWhere((p) => new File(p).existsSync(),
298+
orElse: () => paths.first);
299+
}
300+
295301
String findAssetLocation(String uri, Source srcPath, List<String>
296302
templateRoots) {
297303
if (uri.startsWith('/')) {
298-
var paths = templateRoots.map((r) => '$r/$uri');
299-
return paths.firstWhere((p) => new File(p).existsSync(),
300-
orElse: () => paths.first);
304+
return _resolveInTemplateRoots(uri, templateRoots);
301305
}
302306
// Otherwise let the sourceFactory resolve for packages, and relative paths.
303307
Source source = sourceCrawler.context.sourceFactory

0 commit comments

Comments
 (0)