Skip to content

Commit

Permalink
fix(#6338): respect original indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Feb 27, 2023
1 parent 71743ae commit 0812599
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/create-astro/src/actions/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0812599

Please sign in to comment.