mirror of
https://github.com/Axorax/awesome-free-apps.git
synced 2025-12-17 09:45:21 +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") {
|
function testLinksReachable(file = "README.md") {
|
||||||
console.log(`Testing links in \x1b[32m${file}\x1b[0m`);
|
console.log(`Testing links in \x1b[32m${file}\x1b[0m`);
|
||||||
getLinks(file).forEach((url) => {
|
|
||||||
testUrl(url)
|
const promises = getLinks(file).map(async (url) => {
|
||||||
.then((_) => {})
|
try {
|
||||||
.catch((_) => {});
|
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')) {
|
} else if (args.includes('--all')) {
|
||||||
runAll();
|
runAll();
|
||||||
} else if (args.includes('--test-links')) {
|
} else if (args.includes('--test-links')) {
|
||||||
testLinksReachable("README.md");
|
testLinksInAllFiles()
|
||||||
testLinksReachable("MOBILE.md");
|
|
||||||
} else {
|
} else {
|
||||||
console.log("Usage:");
|
console.log("Usage:");
|
||||||
console.log(" node index.js --categorize Categorize based on icons");
|
console.log(" node index.js --categorize Categorize based on icons");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user