4
4
5
5
import 'dart:io' ;
6
6
7
- import 'package:path/path.dart' as pathos ;
7
+ import 'package:path/path.dart' as path ;
8
8
9
9
/// Returns a path to the directory containing source code for packages such as
10
10
/// kernel, front_end, and analyzer.
11
11
String get packageRoot {
12
12
// If the package root directory is specified on the command line using
13
- // -DpkgRoot=..., use it .
13
+ // ` -DpkgRoot=...` , use that .
14
14
const pkgRootVar =
15
15
bool .hasEnvironment ('pkgRoot' ) ? String .fromEnvironment ('pkgRoot' ) : null ;
16
16
if (pkgRootVar != null ) {
17
- var path = pathos .join (Directory .current.path, pkgRootVar);
18
- if (! path .endsWith (pathos .separator)) path += pathos .separator;
19
- return path ;
17
+ var pkgRootPath = path .join (Directory .current.path, pkgRootVar);
18
+ if (! pkgRootPath .endsWith (path .separator)) pkgRootPath += path .separator;
19
+ return pkgRootPath ;
20
20
}
21
21
// Otherwise try to guess based on the script path.
22
- var scriptPath = pathos .fromUri (Platform .script);
22
+ var scriptPath = path .fromUri (Platform .script);
23
23
var pathFromScript = _tryGetPkgRoot (scriptPath);
24
24
if (pathFromScript != null ) {
25
25
return pathFromScript;
26
26
}
27
27
28
- // Try google3 environment. We expect that all packages that will be
28
+ // Try a Bazel environment. We expect that all packages that will be
29
29
// accessed via this root are configured in the BUILD file, and located
30
30
// inside this single root.
31
31
var runFiles = Platform .environment['TEST_SRCDIR' ];
32
32
var analyzerPackagesRoot = Platform .environment['ANALYZER_PACKAGES_ROOT' ];
33
33
if (runFiles != null && analyzerPackagesRoot != null ) {
34
- return pathos .join (runFiles, analyzerPackagesRoot);
34
+ return path .join (runFiles, analyzerPackagesRoot);
35
35
}
36
36
37
37
// Finally, try the current working directory.
@@ -43,12 +43,12 @@ String get packageRoot {
43
43
throw StateError ('Unable to find sdk/pkg/ in $scriptPath ' );
44
44
}
45
45
46
- /// Try to find the path to the pkg folder from [path ] .
47
- String ? _tryGetPkgRoot (String path ) {
48
- var parts = pathos .split (path );
46
+ /// Tries to find the path to the ' pkg' folder from [searchPath ] .
47
+ String ? _tryGetPkgRoot (String searchPath ) {
48
+ var parts = path .split (searchPath );
49
49
var pkgIndex = parts.indexOf ('pkg' );
50
50
if (pkgIndex != - 1 ) {
51
- return pathos .joinAll (parts.sublist (0 , pkgIndex + 1 )) + pathos .separator;
51
+ return path .joinAll (parts.sublist (0 , pkgIndex + 1 )) + path .separator;
52
52
}
53
53
return null ;
54
54
}
0 commit comments