summaryrefslogtreecommitdiff
path: root/packages/create-astro/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro/src')
-rw-r--r--packages/create-astro/src/actions/template.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts
index 5804fbb58..f99726b1c 100644
--- a/packages/create-astro/src/actions/template.ts
+++ b/packages/create-astro/src/actions/template.ts
@@ -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) {