File size: 529 Bytes
780c9fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 *  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+)?:?(\d+)?/g,
    (_, path, lineNo, columnNo) => {
      if (lineNo) {
        return `[${path}:${lineNo}:${columnNo}](https://github.com/mdn/content/blob/main/${path}?plain=1#L${lineNo})`;
      }
      return `[${path}](https://github.com/mdn/content/blob/main/${path}?plain=1)`;
    },
  ),
);