diff --git a/plugins/packs-integrations.js b/plugins/packs-integrations.js index b7796252c6e..b2a3b5dcedf 100644 --- a/plugins/packs-integrations.js +++ b/plugins/packs-integrations.js @@ -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; }