diff --git a/lib/prepare_security.js b/lib/prepare_security.js index 6e355bfa..943bc60b 100644 --- a/lib/prepare_security.js +++ b/lib/prepare_security.js @@ -203,23 +203,19 @@ export default class PrepareSecurityRelease extends SecurityRelease { } async createVulnerabilitiesJSON(reports, dependencies, releaseDate) { - this.cli.separator('Creating vulnerabilities.json...'); - const file = JSON.stringify({ + this.cli.startSpinner('Creating vulnerabilities.json...'); + const fileContent = JSON.stringify({ releaseDate, reports, dependencies - }, null, 2); + }, null, 2) + '\n'; - const folderPath = path.join(process.cwd(), NEXT_SECURITY_RELEASE_FOLDER); - try { - fs.accessSync(folderPath); - } catch (error) { - fs.mkdirSync(folderPath, { recursive: true }); - } + const folderPath = path.resolve(NEXT_SECURITY_RELEASE_FOLDER); + await fs.promises.mkdir(folderPath, { recursive: true }); const fullPath = path.join(folderPath, 'vulnerabilities.json'); - fs.writeFileSync(fullPath, file); - this.cli.ok(`Created ${fullPath} `); + await fs.promises.writeFile(fullPath, fileContent); + this.cli.stopSpinner(`Created ${fullPath}`); return fullPath; }