Unverified Commit 4a110b62 authored by Janice Collins's avatar Janice Collins Committed by GitHub

Allow snippets tool to be run from arbitrary CWDs (#25243)

* Allow snippets tool to be run from arbitrary CWDs

* Drop use of absolute when using Platform.executable (path is not relative, might require PATH resolution)

* canonicalize paths

* Use path.fromUri consistently to resolve file URIs

* Force commit to try to kick Cirrus

* Force commit to kick Cirrus, again
parent e29b023a
......@@ -124,7 +124,7 @@ class SampleChecker {
/// Finds the location of the snippets script.
String get _snippetsExecutable {
final String platformScriptPath = path.dirname(Platform.script.toFilePath());
final String platformScriptPath = path.dirname(path.fromUri(Platform.script));
return path.canonicalize(path.join(platformScriptPath, '..', 'snippets', 'lib', 'main.dart'));
}
......@@ -206,18 +206,18 @@ class SampleChecker {
if (_snippetsSnapshotPath == null) {
_snippetsSnapshotPath = '$_snippetsExecutable.snapshot';
return Process.runSync(
path.absolute(Platform.executable),
path.canonicalize(Platform.executable),
<String>[
'--snapshot=$_snippetsSnapshotPath',
'--snapshot-kind=app-jit',
path.absolute(_snippetsExecutable),
path.canonicalize(_snippetsExecutable),
]..addAll(args),
workingDirectory: workingDirectory,
);
} else {
return Process.runSync(
path.absolute(Platform.executable),
<String>[path.absolute(_snippetsSnapshotPath)]..addAll(args),
path.canonicalize(Platform.executable),
<String>[path.canonicalize(_snippetsSnapshotPath)]..addAll(args),
workingDirectory: workingDirectory,
);
}
......
......@@ -30,8 +30,8 @@ class _ComponentTuple {
class SnippetGenerator {
SnippetGenerator({Configuration configuration})
: configuration = configuration ??
// This script must be run from dev/docs, so the root is up two levels.
Configuration(flutterRoot: Directory(path.canonicalize(path.join('..', '..')))) {
// Flutter's root is four directories up from this script.
Configuration(flutterRoot: Directory(Platform.environment['FLUTTER_ROOT'] ?? path.canonicalize(path.join(path.dirname(path.fromUri(Platform.script)), '..', '..', '..')))) {
this.configuration.createOutputDirectory();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment