Skip to content

Commit

Permalink
chore: Check copyright and license as one joined substring (#8815)
Browse files Browse the repository at this point in the history
* chore: Check copyright and license as one joined substring

* Update CHANGELOG.md

* Delete misleading comment
  • Loading branch information
pedrottimark authored and jeysal committed Aug 13, 2019
1 parent 9406708 commit 0d48344
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- `[jest-core]` Add `getVersion` (moved from `jest-cli`) ([#8706](https://github.com/facebook/jest/pull/8706))
- `[docs]` Fix MockFunctions example that was using toContain instead of toContainEqual ([#8765](https://github.com/facebook/jest/pull/8765))
- `[*]` Make sure copyright header comment includes license ([#8783](https://github.com/facebook/jest/pull/8783))
- `[*]` Check copyright and license as one joined substring ([#8815](https://github.com/facebook/jest/pull/8815))
- `[docs]` Fix WatchPlugins `jestHooks.shouldRunTestSuite` example that receives an object ([#8784](https://github.com/facebook/jest/pull/8784))
- `[*]` Enforce LF line endings ([#8809](https://github.com/facebook/jest/pull/8809))

Expand Down
22 changes: 7 additions & 15 deletions scripts/checkCopyrightHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,16 @@ const INCLUDED_PATTERNS = [
/\.[^/]+$/,
];

const COPYRIGHT_HEADER =
'Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.';
const LICENSE1 =
'This source code is licensed under the MIT license found in the';
const LICENSE2 = 'LICENSE file in the root directory of this source tree.';
const COPYRIGHT_LICENSE = [
' * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.',
' *',
' * This source code is licensed under the MIT license found in the',
' * LICENSE file in the root directory of this source tree.',
].join('\n');

function needsCopyrightHeader(file) {
const contents = getFileContents(file);

// Match lines individually to avoid false positive for:
// comment block versus lines
// line ending LF versus CRLF
return (
contents.trim().length > 0 &&
(!contents.includes(COPYRIGHT_HEADER) ||
!contents.includes(LICENSE1) ||
!contents.includes(LICENSE2))
);
return contents.trim().length > 0 && !contents.includes(COPYRIGHT_LICENSE);
}

function check() {
Expand Down

0 comments on commit 0d48344

Please sign in to comment.