mirror of
https://github.com/ipfs/awesome-ipfs.git
synced 2024-07-04 18:41:20 +00:00
6d5eef146a
* chore: ignore files created by awesome_bot * feat: auto-update README.md when PRs are created * feat: use danger to post awesome_bot results on PRs * chore: wut * Update pull_requests.yml * chore: fake-test * adjust branch used by github-push-action * chore: ensure checkout uses the branch * chore: update README.md * chore: modify dangerfile and workflow ordering * remove fake addition to videos.yaml * chore: update README.md * chore: rename pull_requests.yml * temp: always display awesomeBot results * Revert "temp: always display awesomeBot results" This reverts commitacaef1f4f2
. * chore(deps): install danger as devDep * feat: cache node_modules and readme * Update pull_requests.yml * chore: remove ad-m/github-push-action see https://github.com/ad-m/github-push-action/issues/104 * tmp: PR-demo * Rebuild * Revert "tmp: PR-demo" This reverts commit8bed1326f0
. * Rebuild * fix: no need to push readme update * fix: no need to push readme update readme is updated during 'Rebuild' commit from data.yml * chore: run danger via npm script instead of npx * feat: remove replace circleci cron with github action this github action should open a PR removing broken links automatically Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
29 lines
1010 B
JavaScript
29 lines
1010 B
JavaScript
/**
|
|
* This file assumes that awesome_bot has already been ran.
|
|
*/
|
|
const markdownTable = require('../ab-results-README.md-markdown-table.json')
|
|
const fs = require('fs').promises
|
|
const { join } = require('path')
|
|
|
|
const dir = join(__dirname, '../data')
|
|
|
|
if (markdownTable.error) {
|
|
const brokenLinks = require('../ab-results-README.md-filtered.json').map((resultsData) => resultsData.link);
|
|
(async () => {
|
|
const files = (await fs.readdir(dir)).map(file => join(dir, file))
|
|
|
|
for await (const filePath of files) {
|
|
let fileContents = await fs.readFile(filePath, 'utf8')
|
|
brokenLinks.forEach((brokenLink) => {
|
|
console.log('Searching for "' + brokenLink + '" in ' + filePath)
|
|
const regex = new RegExp(brokenLink, 'g')
|
|
if (fileContents.match(regex)) {
|
|
fileContents = fileContents.replace(regex, '')
|
|
console.log('Removed "' + brokenLink + '" from ' + filePath)
|
|
}
|
|
})
|
|
await fs.writeFile(filePath, fileContents, 'utf8')
|
|
}
|
|
})()
|
|
}
|