Skip to content

Commit 57f2839

Browse files
committed
Store pub directory for reuse
1 parent cd8e74d commit 57f2839

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

pkgs/test_core/lib/src/runner/version.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,17 @@ final String? testVersion = _readWorkspaceRef() ?? _readPubspecLock();
1717

1818
String? _readWorkspaceRef() {
1919
try {
20-
final workspaceRefPath = p.join('.dart_tool', 'pub', 'workspace_ref.json');
21-
final workspaceRefFile = File(workspaceRefPath);
20+
final pubDirectory = p.join('.dart_tool', 'pub');
21+
final workspaceRefFile = File(p.join(pubDirectory, 'workspace_ref.json'));
2222
if (!workspaceRefFile.existsSync()) return null;
23-
final ref = jsonDecode(workspaceRefFile.readAsStringSync());
24-
if (ref is! Map) return null;
25-
final relativeRoot = ref['workspaceRoot'];
23+
final workspaceRef = jsonDecode(workspaceRefFile.readAsStringSync());
24+
if (workspaceRef is! Map) return null;
25+
final relativeRoot = workspaceRef['workspaceRoot'];
2626
if (relativeRoot is! String) return null;
2727
final packageGraphPath = p.normalize(
28-
p.join(
29-
'.dart_tool',
30-
'pub',
31-
relativeRoot,
32-
'.dart_tool',
33-
'package_graph.json',
34-
),
28+
p.join(pubDirectory, relativeRoot, '.dart_tool', 'package_graph.json'),
3529
);
36-
final packageGraphFile = File(packageGraphPath);
37-
final packageGraph = jsonDecode(packageGraphFile.readAsStringSync());
30+
final packageGraph = jsonDecode(File(packageGraphPath).readAsStringSync());
3831
if (packageGraph is! Map) return null;
3932
final packages = packageGraph['packages'];
4033
if (packages is! List) return null;

0 commit comments

Comments
 (0)