Skip to content

Commit

Permalink
fix: correct jsdocs links (#938)
Browse files Browse the repository at this point in the history
* fix: correct jsdocs links

* chore: update depcheck

* chore: code style
  • Loading branch information
Cafe137 authored Aug 8, 2024
1 parent 0a69957 commit 105909d
Show file tree
Hide file tree
Showing 8 changed files with 550 additions and 486 deletions.
36 changes: 36 additions & 0 deletions linkcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { default: axios } = require('axios')
const { Strings } = require('cafe-utility')
const { readdirSync, statSync, readFileSync } = require('fs')
const { join } = require('path')

main()

function main() {
walk('src')
}

function walk(dir) {
const files = readdirSync(dir)
for (const file of files) {
const path = join(dir, file)
if (statSync(path).isDirectory()) {
walk(path)
} else {
check(path)
}
}
}

function check(path) {
const content = readFileSync(path, 'utf8')
const links = Strings.extractAllBlocks(content, {
opening: '](https://docs.ethswarm.org',
closing: ')',
})
for (const link of links) {
const cleanLink = link.replaceAll('](', '').replaceAll(')', '')
axios.get(cleanLink).catch(error => {
console.error(path, cleanLink, error.response.status)
})
}
}
Loading

0 comments on commit 105909d

Please sign in to comment.