|
1 | | -const fs = require('fs'); |
2 | | - |
3 | | -const SOURCE = '.all-contributorsrc'; |
4 | | -const TARGET = |
5 | | - './projects/elements-demo/src/app/features/contribute/contribute/contribute.component.html'; |
6 | | -const TOKEN_START = '<!-- ALL-CONTRIBUTORS-LIST:START -->'; |
7 | | -const TOKEN_END = '<!-- ALL-CONTRIBUTORS-LIST:END -->'; |
8 | | -const PATTERN = new RegExp(`${TOKEN_START}[\\s\\S]*${TOKEN_END}`, 'gim'); |
9 | | - |
10 | | -const contributors = JSON.parse(fs.readFileSync(SOURCE, 'utf8')).contributors; |
11 | | -const content = fs.readFileSync(TARGET, 'utf8'); |
12 | | - |
13 | | -const data = contributors |
14 | | - .map( |
15 | | - c => ` |
16 | | - <a class="contributor" href="${c.profile}" target="_blank"> |
17 | | - <img src="${c.avatar_url}"> |
18 | | - <span>${c.name}</span> |
19 | | - </a> |
20 | | -` |
21 | | - ) |
22 | | - .join('\n'); |
23 | | -const replacement = `${TOKEN_START}${data}${TOKEN_END}`; |
24 | | -const adjustedContent = content.replace(PATTERN, replacement); |
25 | | - |
26 | | -fs.writeFileSync(TARGET, adjustedContent); |
27 | | - |
28 | | -console.log(`${contributors.length} contributors added to HTML`); |
| 1 | +const fs = require('fs'); |
| 2 | + |
| 3 | +const SOURCE = '.all-contributorsrc'; |
| 4 | +const TARGET = |
| 5 | + './projects/elements-demo/src/app/features/contribute/contribute.component.html'; |
| 6 | +const TOKEN_START = '<!-- ALL-CONTRIBUTORS-LIST:START -->'; |
| 7 | +const TOKEN_END = '<!-- ALL-CONTRIBUTORS-LIST:END -->'; |
| 8 | +const PATTERN = new RegExp(`${TOKEN_START}[\\s\\S]*${TOKEN_END}`, 'gim'); |
| 9 | + |
| 10 | +const contributors = JSON.parse(fs.readFileSync(SOURCE, 'utf8')).contributors; |
| 11 | +const content = fs.readFileSync(TARGET, 'utf8'); |
| 12 | + |
| 13 | +const data = contributors |
| 14 | + .map( |
| 15 | + (c) => ` |
| 16 | + <a class="contributor" href="${c.profile}" target="_blank"> |
| 17 | + <img src="${c.avatar_url}"> |
| 18 | + <span>${c.name}</span> |
| 19 | + </a> |
| 20 | +` |
| 21 | + ) |
| 22 | + .join('\n'); |
| 23 | +const replacement = `${TOKEN_START}${data}${TOKEN_END}`; |
| 24 | +const adjustedContent = content.replace(PATTERN, replacement); |
| 25 | + |
| 26 | +fs.writeFileSync(TARGET, adjustedContent); |
| 27 | + |
| 28 | +console.log(`${contributors.length} contributors added to HTML`); |
0 commit comments