Skip to content

Commit a6fc90b

Browse files
UnikZnex3
authored andcommitted
Support UNLICENSE file (#1553)
1 parent bd769e9 commit a6fc90b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/src/validator/license.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LicenseValidator extends Validator {
1616
Future validate() {
1717
return new Future.sync(() {
1818
var licenseLike =
19-
new RegExp(r"^([a-zA-Z0-9]+[-_])?(LICENSE|COPYING)(\..*)?$");
19+
new RegExp(r"^(([a-zA-Z0-9]+[-_])?(LICENSE|COPYING)|UNLICENSE)(\..*)?$");
2020
if (entrypoint.root
2121
.listFiles(recursive: false, useGitIgnore: true)
2222
.map(path.basename)
@@ -25,7 +25,7 @@ class LicenseValidator extends Validator {
2525
}
2626

2727
errors.add(
28-
"You must have a COPYING or LICENSE file in the root directory.\n"
28+
"You must have a COPYING, LICENSE or UNLICENSE file in the root directory.\n"
2929
"An open-source license helps ensure people can legally use your "
3030
"code.");
3131
});

test/validator/license_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ main() {
2727
expectNoValidationError(license);
2828
});
2929

30+
integration('has an UNLICENSE file', () {
31+
schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE')));
32+
d.file(path.join(appPath, 'UNLICENSE'), '').create();
33+
expectNoValidationError(license);
34+
});
35+
3036
integration('has a prefixed LICENSE file', () {
3137
schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE')));
3238
d.file(path.join(appPath, 'MIT_LICENSE'), '').create();
@@ -47,6 +53,13 @@ main() {
4753
expectValidationError(license);
4854
});
4955

56+
integration('has a prefixed UNLICENSE file', () {
57+
d.validPackage.create();
58+
schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE')));
59+
d.file(path.join(appPath, 'MIT_UNLICENSE'), '').create();
60+
expectValidationError(license);
61+
});
62+
5063
integration('has a .gitignored LICENSE file', () {
5164
var repo = d.git(appPath, [d.file(".gitignore", "LICENSE")]);
5265
d.validPackage.create();

0 commit comments

Comments
 (0)