diff --git a/bin/commands/execute.js b/bin/commands/execute.js index bd1ca69..37b6d40 100644 --- a/bin/commands/execute.js +++ b/bin/commands/execute.js @@ -43,19 +43,23 @@ export async function execute(options = {}) { console.log(`>> title: ${kleur.cyan().bold(report.title)}`); console.log(`>> reporters: ${kleur.magenta().bold(report.reporters.join(","))}\n`); - store.run(config, () => { - fetchPackagesAndRepositoriesData() - .then((data) => { - if (debugMode) { - debug(data); - } - - return reporting.proceed(data); - }) - .catch((error) => { - console.error(error); - }) - .finally(teardown); + store.run(config, async() => { + try { + const data = await fetchPackagesAndRepositoriesData(); + if (debugMode) { + debug(data); + } + await reporting.proceed(data); + console.log(kleur.green().bold("\n>> Security report successfully generated! Enjoy 🚀.\n")); + } + catch (error) { + console.error(error); + } + finally { + await fs.rm(CONSTANTS.DIRS.CLONES, { + recursive: true, force: true + }); + } }); } @@ -71,14 +75,6 @@ function init() { ); } -function teardown() { - console.log(kleur.green().bold("\n>> Security report successfully generated! Enjoy 🚀.\n")); - - return fs.rm(CONSTANTS.DIRS.CLONES, { - recursive: true, force: true - }); -} - function debug(obj) { const filePath = path.join(CONSTANTS.DIRS.REPORTS, `debug-pkg-repo.txt`); writeFileSync(filePath, inspect(obj, { showHidden: true, depth: null }), "utf8");