Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.0.4-wip

- Locate the Dart SDK and `dart` executable via `package:cli_util` when running in AOT mode.

## 4.0.3

- Fix failing debugger expression evaluation.
Expand Down
22 changes: 10 additions & 12 deletions webdev/lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:io';

import 'package:cli_util/cli_util.dart';
import 'package:path/path.dart' as p;
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart';
Expand All @@ -28,18 +29,15 @@ void serveHttpRequests(

/// The path to the root directory of the SDK.
final String _sdkDir = (() {
// The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
// "/path/to/sdk".
final String dartExecutable = Platform.isWindows
// Use 'where.exe' to support powershell as well
? (Process.runSync('where.exe', ['dart.exe']).stdout as String)
.split(RegExp('(\r\n|\r|\n)'))
.first
: Process.runSync('which', ['dart']).stdout;
final aboveExecutable = p.dirname(p.dirname(dartExecutable));
assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
return aboveExecutable;
final sdk = sdkPath;
if (sdk == null) {
throw StateError('Unable to locate the Dart SDK.');
}
assert(FileSystemEntity.isFileSync(p.join(sdk, 'version')));
return sdk;
})();

final String dartPath = p.join(_sdkDir, 'bin', 'dart');
final String dartPath =
dartExecutable ??
p.join(_sdkDir, 'bin', Platform.isWindows ? 'dart.exe' : 'dart');
final String devToolsPath = p.join(_sdkDir, 'bin', 'resources', 'devtools');
2 changes: 1 addition & 1 deletion webdev/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webdev/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webdev
# Every time this changes you need to run `dart run build_runner build`.
version: 4.0.3
version: 4.0.4-wip
# We should not depend on a dev SDK before publishing.
# publish_to: none
description: >-
Expand All @@ -15,6 +15,7 @@ dependencies:
async: ^2.9.0
build_daemon: ^4.1.4
browser_launcher: ^1.1.0
cli_util: ^0.6.0
collection: ^1.15.0
crypto: ^3.0.2
dds: ^5.3.0
Expand Down
6 changes: 6 additions & 0 deletions webdev/test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:webdev/src/serve/utils.dart';
import 'package:webdev/src/util.dart';

void main() {
test('dartPath and devToolsPath resolve via cli_util', () {
expect(File(dartPath).existsSync(), isTrue);
expect(Directory(devToolsPath).existsSync(), isTrue);
});

late Directory from;
late Directory to;

Expand Down
Loading