Skip to content

Commit 8f7349c

Browse files
committed
possible fix
1 parent 0cb83c4 commit 8f7349c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

bin/scan/writeBrokenLinks.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,25 @@ function writeToFile(data, PATH, fluff) {
3838
async function writeBrokenLinks(links, PATH, fluff) {
3939
for (const link of links) {
4040
if (isLocalhostUrl(link)) { continue }
41-
linkCheck(link, function (err, result) {
42-
if (err) {
43-
console.error('Error: failed to validate', link);
44-
process.exit(1);
45-
}
41+
42+
try {
43+
const result = await new Promise((resolve, reject) => {
44+
linkCheck(link, function (err, result) {
45+
if (err) {
46+
reject(err);
47+
} else {
48+
resolve(result);
49+
}
50+
});
51+
});
52+
4653
if (result.status === "dead") {
4754
writeToFile(link, PATH, fluff);
4855
}
49-
});
56+
} catch (err) {
57+
console.error('Error: failed to validate', link, err);
58+
// Handle the error as needed, maybe continue to the next link instead of exiting
59+
}
5060
}
5161

5262
return;

0 commit comments

Comments
 (0)