Skip to content

Commit 5420951

Browse files
committed
Allow webdev to be run from an executable (for 'dart install')
1 parent d2e5593 commit 5420951

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

webdev/lib/src/util.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ void serveHttpRequests(
3030
final String _sdkDir = (() {
3131
// The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
3232
// "/path/to/sdk".
33-
final aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable));
33+
final String dartExecutable = Platform.isWindows
34+
// Use 'where.exe' to support powershell as well
35+
? (Process.runSync('where.exe', ['dart.exe']).stdout as String)
36+
.split(RegExp('(\r\n|\r|\n)'))
37+
.first
38+
: Process.runSync('which', ['dart']).stdout;
39+
final aboveExecutable = p.dirname(p.dirname(dartExecutable));
3440
assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
3541
return aboveExecutable;
3642
})();

0 commit comments

Comments
 (0)