-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Cleanup incorrect links in CHANGELOG.md (#13857)
- Loading branch information
1 parent
cfa2d39
commit 423142c
Showing
4 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
import fs from 'graceful-fs'; | ||
|
||
const linkRegex = | ||
/\[#(\d+)\]\(https:\/\/github.com\/facebook\/jest\/(issues|pull)\/(\d+)\)/g; | ||
|
||
const changelogPath = 'CHANGELOG.md'; | ||
const data = fs.readFileSync(changelogPath, 'utf-8'); | ||
|
||
let error = false; | ||
let lineNumber = 1; | ||
for (const line of data.split('\n')) { | ||
for (const match of line.matchAll(linkRegex)) | ||
if (match[1] !== match[3]) { | ||
const column = match.index + 1; | ||
console.error( | ||
`${changelogPath}:${lineNumber}:${column}: error: ` + | ||
`Link is incorrect: ${match[0]}`, | ||
); | ||
error = true; | ||
} | ||
++lineNumber; | ||
} | ||
|
||
process.exit(error ? 1 : 0); |