Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.0.0-beta.11

* Properly load the Dart SDK license when it's in the directory above the SDK,
as in a Homebrew installation.

# 1.0.0-beta.10

* **Breaking change:** All configurable variables are now defined as
Expand Down
19 changes: 15 additions & 4 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ Future<String> get license => _licenseMemo.runOnce(() async {
// from Dart Team packages.
var licenses = <String, List<String>>{};
var thisPackageLicense = _readLicense(".");

if (thisPackageLicense != null) {
licenses[thisPackageLicense] = [humanName.value];
}

licenses
.putIfAbsent(
File(p.join(sdkDir.path, 'LICENSE')).readAsStringSync(), () => [])
.add("Dart SDK");
licenses.putIfAbsent(_readSdkLicense(), () => []).add("Dart SDK");

// Parse the package config rather than the pubspec so we include transitive
// dependencies. This also includes dev dependencies, but it's possible those
Expand Down Expand Up @@ -132,6 +130,19 @@ final _licenseMemo = AsyncMemoizer<String>();
final _licenseRegExp =
RegExp(r"^(([a-zA-Z0-9]+[-_])?(LICENSE|COPYING)|UNLICENSE)(\..*)?$");

/// Returns the contents of the `LICENSE` file in [sdkDir].
String _readSdkLicense() {
final dartLicense = File(p.join(sdkDir.path, 'LICENSE'));

if (dartLicense.existsSync()) {
return dartLicense.readAsStringSync();
} else {
// Homebrew's Dart SDK installation puts the license in the directory above
// the SDK, so if it's not in the SDK itself check there.
return File(p.join(sdkDir.parent.path, 'LICENSE')).readAsStringSync();
}
}

/// Returns the contents of the `LICENSE` file in [dir], with various possible
/// filenames and extensions, or `null`.
String _readLicense(String dir) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cli_pkg
version: 1.0.0-beta.10
version: 1.0.0-beta.11
description: Grinder tasks for releasing Dart CLI packages.
homepage: https://github.com/google/dart_cli_pkg

Expand Down