1+ import fs from 'node:fs'
12import path from 'node:path'
23import process from 'node:process'
34import remarkEmoji from 'remark-emoji'
@@ -20,6 +21,29 @@ import { unified } from 'unified'
2021const currentPath = process . cwd ( )
2122const folderName = path . basename ( currentPath )
2223
24+ function getPackageJsonFiles ( directory ) {
25+ const files = fs . readdirSync ( directory )
26+ const packageJsonFiles = [ ]
27+ for ( const file of files ) {
28+ const filePath = path . join ( directory , file )
29+ const stat = fs . statSync ( filePath )
30+ if ( stat . isDirectory ( ) && file !== 'node_modules' ) {
31+ packageJsonFiles . push ( ...getPackageJsonFiles ( filePath ) )
32+ } else if ( file === 'package.json' ) {
33+ packageJsonFiles . push ( filePath )
34+ }
35+ }
36+ return packageJsonFiles
37+ }
38+
39+ const pkgPaths = getPackageJsonFiles ( currentPath )
40+ const pkgNames = pkgPaths . map ( ( pkgPath ) => {
41+ return JSON . parse ( fs . readFileSync ( path . join ( pkgPath ) , 'utf8' ) ) . name
42+ } )
43+ const ignoreAllNpmUrls = pkgNames . map (
44+ ( pkg ) => `https://www.npmjs.com/package/${ pkg } ` ,
45+ )
46+
2347export default {
2448 settings : {
2549 bullet : '-' ,
@@ -38,7 +62,11 @@ export default {
3862 remarkLintNoDeadUrls ,
3963 {
4064 // TODO: https://github.com/wooorm/dead-or-alive/issues/3
41- skipUrlPatterns : [ `https://tiagoporto.github.io/${ folderName } /` ] ,
65+ skipUrlPatterns : [
66+ `https://tiagoporto.github.io/${ folderName } /` ,
67+ // NOTE: avoid npm 403 errors
68+ ...ignoreAllNpmUrls ,
69+ ] ,
4270 skipLocalhost : true ,
4371 skipOffline : true ,
4472 deadOrAliveOptions : {
0 commit comments