Skip to content

Commit

Permalink
docs: add error handling to writeFile
Browse files Browse the repository at this point in the history
  • Loading branch information
addetz committed Nov 11, 2024
1 parent f92f2f5 commit 49dde45
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions plugins/packs-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,19 +340,25 @@ async function mapRepositories(repositories) {
}
return acc;
}, []);

open(`${dirname}${repos_filename}`, "w+", (err, fd) => {
if (err) {
logger.error("An error occurred while opening the JSON file:", err);
return;
}
try {
writeFile(`${dirname}${repos_filename}`, JSON.stringify(repoMap), (err) => {
if (err) {
logger.error("An error occurred while writing the JSON file:", err);
writeFile(`${dirname}${repos_filename}`, JSON.stringify(repoMap), (err1) => {
if (err1) {
logger.error("An error occurred while writing the JSON file:", err1);
}
});
} finally {
close(fd, (err1) => {
if (err1) logger.error("An error occurred while closing the file:", err1);
close(fd, (err2) => {
if (err2) logger.error("An error occurred while closing the file:", err2);
});
}
});

return repoMap;
}

Expand Down

0 comments on commit 49dde45

Please sign in to comment.