Remove redundant comments when astro add update astro.config.mjs (#6412)

* Remove redundant comments when  update

* add \n

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
李瑞丰 2023-03-03 23:41:11 +08:00 committed by GitHub
parent 0abd1d3e42
commit cd8469947b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Remove redundant comments when `astro add` update `astro.config.mjs`

View file

@ -507,7 +507,7 @@ async function updateAstroConfig({
let output = await generate(ast);
const comment = '// https://astro.build/config';
const defaultExport = 'export default defineConfig';
output = output.replace(` ${comment}`, '');
output = output.replace(`\n${comment}`, '');
output = output.replace(`${defaultExport}`, `\n${comment}\n${defaultExport}`);
if (input === output) {