1414╚─────────────────────────────────────────────────────────────────────────────*/
1515
1616// Node.js
17- import { existsSync , mkdtempSync , rmSync , readFileSync } from 'node:fs' ;
17+ import { existsSync , statSync , mkdtempSync , rmSync , readFileSync } from 'node:fs' ;
1818import { join } from 'node:path' ;
1919import { tmpdir } from 'node:os' ;
2020import { spawnSync } from 'node:child_process' ;
@@ -71,7 +71,7 @@ const checkUnique = (config) => {
7171 loops ,
7272 'Redirect sources in docs.json must not self-reference in destinations!' ,
7373 ) ,
74- }
74+ } ;
7575 }
7676 const navLinks = getNavLinksSet ( config ) ;
7777 const navOverrides = redirectSources . filter ( ( it ) => navLinks . has ( fmt ( it ) ) ) ;
@@ -83,7 +83,7 @@ const checkUnique = (config) => {
8383 navOverrides ,
8484 'Redirect sources in docs.json must not replace existing paths!' ,
8585 ) ,
86- }
86+ } ;
8787 }
8888 // Otherwise
8989 return { ok : true } ;
@@ -111,7 +111,11 @@ const checkExist = (config) => {
111111 return false ;
112112 }
113113 const rel = it . replace ( / ^ \/ + / , '' ) . replace ( / # .* $ / , '' ) . replace ( / \? .* $ / , '' ) ;
114- return [ rel === '' ? `index.mdx` : `${ rel } /index.mdx` , `${ rel } .mdx` , `${ rel } ` ] . some ( existsSync ) === false ;
114+ return (
115+ [ rel === '' ? `index.mdx` : `${ rel } /index.mdx` , `${ rel } .mdx` , `${ rel } ` ] . some (
116+ ( path ) => existsSync ( path ) && statSync ( path ) . isFile ( ) ,
117+ ) === false
118+ ) ;
115119 } ) ;
116120 if ( repoIssuesDestsExist ) {
117121 console . log ( composeWarning ( 'Found GitHub issue destinations!' ) ) ;
@@ -304,11 +308,11 @@ const main = async () => {
304308 console . log ( res . error ) ;
305309 } else {
306310 console . log ( composeSuccess ( rawSuccessMsg ) ) ;
307- } ;
311+ }
308312 if ( shouldRunAll ) {
309313 console . log ( ) ; // intentional break
310314 }
311- }
315+ } ;
312316
313317 if ( shouldRunAll || argUnique ) {
314318 console . log ( '🏁 Checking the uniqueness of redirect sources in docs.json...' ) ;
0 commit comments