Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: lib/src/util/io.dart

Issue 1051133002: *Properly* fix that package-root bug. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/compiler_pool.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.util.io; 5 library test.util.io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 /// [LoadException] is thrown. 93 /// [LoadException] is thrown.
94 String packageRootFor(String path, [String override]) { 94 String packageRootFor(String path, [String override]) {
95 var packageRoot = override == null 95 var packageRoot = override == null
96 ? p.join(p.dirname(path), 'packages') 96 ? p.join(p.dirname(path), 'packages')
97 : override; 97 : override;
98 98
99 if (!new Directory(packageRoot).existsSync()) { 99 if (!new Directory(packageRoot).existsSync()) {
100 throw new LoadException(path, "Directory $packageRoot does not exist."); 100 throw new LoadException(path, "Directory $packageRoot does not exist.");
101 } 101 }
102 102
103 return p.toUri(packageRoot).toString(); 103 return packageRoot;
104 } 104 }
105 105
106 /// The library name must be globally unique, or the wrong library path may be 106 /// The library name must be globally unique, or the wrong library path may be
107 /// returned. 107 /// returned.
108 String libraryPath(Symbol libraryName, {String packageRoot}) { 108 String libraryPath(Symbol libraryName, {String packageRoot}) {
109 var lib = currentMirrorSystem().findLibrary(libraryName); 109 var lib = currentMirrorSystem().findLibrary(libraryName);
110 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); 110 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri);
111 111
112 // TODO(nweiz): is there a way to avoid assuming this is being run next to a 112 // TODO(nweiz): is there a way to avoid assuming this is being run next to a
113 // packages directory?. 113 // packages directory?.
114 if (packageRoot == null) packageRoot = p.absolute('packages'); 114 if (packageRoot == null) packageRoot = p.absolute('packages');
115 return p.join(packageRoot, p.fromUri(lib.uri.path)); 115 return p.join(packageRoot, p.fromUri(lib.uri.path));
116 } 116 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/compiler_pool.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698