-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to check incoming branch for 404s per #1726
- Loading branch information
1 parent
9f9ba5a
commit 89f1fb5
Showing
3 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
import Sitemapper from 'sitemapper'; | ||
import http from 'http'; | ||
|
||
|
||
// https://github.com/seantomburke/sitemapper | ||
const sitemapper = new Sitemapper(); | ||
const testUrl = 'http://localhost:1313' | ||
sitemapper.timeout = 1000; | ||
|
||
sitemapper | ||
.fetch('https://docs.communityhealthtoolkit.org/sitemap.xml') | ||
.then(({ url, sites }) => { | ||
// console.log(`url:${url}`, 'sites:', sites); | ||
sites.forEach((docUrl) => { | ||
docUrl = testUrl + docUrl.replace( | ||
'https://docs.communityhealthtoolkit.org', | ||
'' | ||
); | ||
http.get(docUrl, res => { | ||
let data = []; | ||
const headerDate = res.headers && res.headers.date ? res.headers.date : 'no response date'; | ||
console.log('URL:', docUrl, 'Status Code:', res.statusCode); | ||
}).on('error', err => { | ||
console.log('Error: ', err.message); | ||
}); | ||
}); | ||
console.log(`url:${url}`); | ||
|
||
}) | ||
.catch((error) => console.log(error)); | ||
|
||
|
||
|
Oops, something went wrong.