mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Respect original package.json
indentation (#6375)
* fix(#6338): respect original indentation * chore: add changeset
This commit is contained in:
parent
71743aeca7
commit
754c5ca9aa
2 changed files with 10 additions and 3 deletions
5
.changeset/real-balloons-cough.md
Normal file
5
.changeset/real-balloons-cough.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
Respect original `package.json` indentation
|
|
@ -50,17 +50,19 @@ const FILES_TO_UPDATE = {
|
|||
'package.json': (file: string, overrides: { name: string }) =>
|
||||
fs.promises
|
||||
.readFile(file, 'utf-8')
|
||||
.then((value) =>
|
||||
.then((value) => {
|
||||
// Match first indent in the file or fallback to `\t`
|
||||
const indent = /(^\s+)/m.exec(value)?.[1] ?? '\t';
|
||||
fs.promises.writeFile(
|
||||
file,
|
||||
JSON.stringify(
|
||||
Object.assign(JSON.parse(value), Object.assign(overrides, { private: undefined })),
|
||||
null,
|
||||
'\t'
|
||||
indent
|
||||
),
|
||||
'utf-8'
|
||||
)
|
||||
),
|
||||
}),
|
||||
};
|
||||
|
||||
export default async function copyTemplate(tmpl: string, ctx: Context) {
|
||||
|
|
Loading…
Reference in a new issue