-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert file paths to GitHub code links
- Loading branch information
1 parent
2e5c6c9
commit 0fc1ea1
Showing
2 changed files
with
18 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* The script converts file paths to GitHub source links in the provided text. | ||
* Usage: node scripts/linkify-logs.js ${logs} | ||
*/ | ||
|
||
const logs = process.argv[2]; | ||
|
||
console.log( | ||
logs.replaceAll(/(files\/.*?\/index.md):?(\d+)?/g, (_, path, lineNo) => { | ||
let link = `[${path}](https://github.com/mdn/content/blob/main/${path}?plain=1`; | ||
if (lineNo) { | ||
return link + `#L${lineNo}):${lineNo}`; | ||
} | ||
return link + `)`; | ||
}), | ||
); |