mirror of
https://github.com/Axorax/awesome-free-apps.git
synced 2025-12-17 17:55:26 +00:00
feat: update testing links being reachable
This commit is contained in:
parent
f3c6f4ec3d
commit
81c5a85f7a
29
index.js
29
index.js
@ -121,14 +121,30 @@ function testUrl(url) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Test if all links in a given file are valid (reachable) */
|
||||
/**
|
||||
* Test if all links in a given file are valid (reachable)
|
||||
* @param {string} file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
function testLinksReachable(file = "README.md") {
|
||||
console.log(`Testing links in \x1b[32m${file}\x1b[0m`);
|
||||
getLinks(file).forEach((url) => {
|
||||
testUrl(url)
|
||||
.then((_) => {})
|
||||
.catch((_) => {});
|
||||
|
||||
const promises = getLinks(file).map(async (url) => {
|
||||
try {
|
||||
await testUrl(url);
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
async function testLinksInAllFiles() {
|
||||
try {
|
||||
await testLinksReachable("README.md");
|
||||
await testLinksReachable("MOBILE.md");
|
||||
} catch (error) {
|
||||
console.error("An error occurred:", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -256,8 +272,7 @@ if (args.includes('--analyze')) {
|
||||
} else if (args.includes('--all')) {
|
||||
runAll();
|
||||
} else if (args.includes('--test-links')) {
|
||||
testLinksReachable("README.md");
|
||||
testLinksReachable("MOBILE.md");
|
||||
testLinksInAllFiles()
|
||||
} else {
|
||||
console.log("Usage:");
|
||||
console.log(" node index.js --categorize Categorize based on icons");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user