@@ -49,9 +49,7 @@ function tempCB(dirPath, dirs, files) {
4949// Load and display ignore list
5050var fs = require ( 'fs' ) ;
5151const { link } = require ( 'fs-extra' ) ;
52- var ignore = JSON . parse (
53- fs . readFileSync ( './libs/link-validator-ignore.json' , 'utf8' )
54- ) ;
52+ var ignore = JSON . parse ( fs . readFileSync ( './libs/link-validator-ignore.json' , 'utf8' ) ) ;
5553console . log ( colors . bold ( '| > Ignore list' ) ) ;
5654ignore . forEach ( ( element ) => {
5755 console . log ( '|' , colors . bold . yellow ( element ) ) ;
@@ -119,14 +117,9 @@ async function testLink(url, filePath, ignoreTimeout) {
119117 //console.log('> Target URL:', url);
120118
121119 // Look for urlAnchor in response.data.
122- if (
123- urlAnchor &&
124- response . data . indexOf ( 'href="' + urlAnchor + '"' ) === - 1
125- ) {
120+ if ( urlAnchor && response . data . indexOf ( 'href="' + urlAnchor + '"' ) === - 1 ) {
126121 //console.log(colors.red('> Anchor was NOT found in the response data.'));
127- throw new Error (
128- 'Did not find anchor in the response data: ' + urlAnchor
129- ) ;
122+ throw new Error ( 'Did not find anchor in the response data: ' + urlAnchor ) ;
130123 }
131124 // else {
132125 //console.log('> Anchor was found in the response data.');
@@ -150,11 +143,7 @@ async function testLink(url, filePath, ignoreTimeout) {
150143 return 0 ;
151144 } catch ( error ) {
152145 // If a timeout try one more time
153- if (
154- ! ignoreTimeout &&
155- error . code == 'ECONNABORTED' &&
156- error . toString ( ) . indexOf ( 'Error: timeout' ) > - 1
157- ) {
146+ if ( ! ignoreTimeout && error . code == 'ECONNABORTED' && error . toString ( ) . indexOf ( 'Error: timeout' ) > - 1 ) {
158147 testLink ( url , filePath , true ) ;
159148 } else {
160149 process . stdout . write ( colors . bold . red ( 'X' ) ) ;
@@ -165,8 +154,7 @@ async function testLink(url, filePath, ignoreTimeout) {
165154}
166155
167156async function run ( task ) {
168- ( console . log ( 'Checking (' + task + ')' , Object . keys ( linksObj ) . length ) ,
169- 'links.' ) ;
157+ ( console . log ( 'Checking (' + task + ')' , Object . keys ( linksObj ) . length ) , 'links.' ) ;
170158 for ( var key in linksObj ) {
171159 if ( linksObj . hasOwnProperty ( key ) ) {
172160 let fail = await testLink ( key , linksObj [ key ] , false ) ;
@@ -202,11 +190,7 @@ function loadLinks() {
202190 // If the URL starts with an anchor (#) tag
203191 // or is to the root (/)
204192 // do nothing
205- } else if (
206- url &&
207- url . indexOf ( 'http://' ) === - 1 &&
208- url . indexOf ( 'https://' ) === - 1
209- ) {
193+ } else if ( url && url . indexOf ( 'http://' ) === - 1 && url . indexOf ( 'https://' ) === - 1 ) {
210194 // These are internal links within the docs
211195 url = baseURL + url ;
212196
0 commit comments