Update license check to find and recognize this license
diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart
index 5f01cca..40e7165 100644
--- a/script/tool/lib/src/license_check_command.dart
+++ b/script/tool/lib/src/license_check_command.dart
@@ -42,6 +42,13 @@
'resource.h', // Generated by VS.
};
+// Third-party packages where the code doesn't have file-level annotation, just
+// the package-level LICENSE file. Each entry must be a directory relative to
+// third_party/packages, as that is the only directory where this is allowed.
+const Set<String> _unannotatedFileThirdPartyDirectories = <String>{
+ 'path_parsing',
+};
+
// Copyright and license regexes for third-party code.
//
// These are intentionally very simple, since there is very little third-party
@@ -69,6 +76,16 @@
r'// Use of this source code is governed by a BSD-style license that can be\n'
r'// found in the LICENSE file\.\n',
),
+ // packages/third_party/path_parsing.
+ RegExp(
+ r'Copyright \(c\) 2018 Dan Field\n\n'
+ r'Permission is hereby granted, free of charge, to any person obtaining a copy\n'
+ r'of this software and associated documentation files \(the "Software"\), to deal\n'
+ r'in the Software without restriction, including without limitation the rights\n'
+ r'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n'
+ r'copies of the Software, and to permit persons to whom the Software is\n'
+ r'furnished to do so, subject to the following conditions:',
+ ),
];
// The exact format of the BSD license that our license files should contain.
@@ -217,10 +234,26 @@
for (final File file in codeFiles) {
print('Checking ${file.path}');
+ // Some third-party directories have code that doesn't annotate each file,
+ // so for those check the LICENSE file instead. This is done even though
+ // it's redundant to re-check it for each file because it ensures that we
+ // are still validating every file individually, rather than having a
+ // codepath where whole directories of files are ignored, which would have
+ // a much worse failure mode.
+ String content;
+ if (_unannotatedFileThirdPartyDirectories.any(
+ (String dir) => file.path.contains('/third_party/packages/$dir/'))) {
+ Directory packageDir = file.parent;
+ while (packageDir.parent.basename != 'packages') {
+ packageDir = packageDir.parent;
+ }
+ content = await packageDir.childFile('LICENSE').readAsString();
+ } else {
+ content = await file.readAsString();
+ }
// On Windows, git may auto-convert line endings on checkout; this should
// still pass since they will be converted back on commit.
- final String content =
- (await file.readAsString()).replaceAll('\r\n', '\n');
+ content = content.replaceAll('\r\n', '\n');
final String firstParyLicense =
firstPartyLicenseBlockByExtension[p.extension(file.path)] ??