@@ -86,14 +86,12 @@ Future<String> get license => _licenseMemo.runOnce(() async {
8686 // from Dart Team packages.
8787 var licenses = < String , List <String >> {};
8888 var thisPackageLicense = _readLicense ("." );
89+
8990 if (thisPackageLicense != null ) {
9091 licenses[thisPackageLicense] = [humanName.value];
9192 }
9293
93- licenses
94- .putIfAbsent (
95- File (p.join (sdkDir.path, 'LICENSE' )).readAsStringSync (), () => [])
96- .add ("Dart SDK" );
94+ licenses.putIfAbsent (_readSdkLicense (), () => []).add ("Dart SDK" );
9795
9896 // Parse the package config rather than the pubspec so we include transitive
9997 // dependencies. This also includes dev dependencies, but it's possible those
@@ -132,6 +130,19 @@ final _licenseMemo = AsyncMemoizer<String>();
132130final _licenseRegExp =
133131 RegExp (r"^(([a-zA-Z0-9]+[-_])?(LICENSE|COPYING)|UNLICENSE)(\..*)?$" );
134132
133+ /// Returns the contents of the `LICENSE` file in [sdkDir] .
134+ String _readSdkLicense () {
135+ final dartLicense = File (p.join (sdkDir.path, 'LICENSE' ));
136+
137+ if (dartLicense.existsSync ()) {
138+ return dartLicense.readAsStringSync ();
139+ } else {
140+ // Homebrew's Dart SDK installation puts the license in the directory above
141+ // the SDK, so if it's not in the SDK itself check there.
142+ return File (p.join (sdkDir.parent.path, 'LICENSE' )).readAsStringSync ();
143+ }
144+ }
145+
135146/// Returns the contents of the `LICENSE` file in [dir] , with various possible
136147/// filenames and extensions, or `null` .
137148String _readLicense (String dir) {
0 commit comments