summaryrefslogtreecommitdiff
path: root/packages/create-astro/src
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2023-10-24 13:48:17 -0500
committerGravatar GitHub <noreply@github.com> 2023-10-24 13:48:17 -0500
commitb236d88addc48d784bd60119fe45750dda900f16 (patch)
tree3c82195505f3514149da61a6cbb51e50aec11608 /packages/create-astro/src
parenta86b41c852ce5c05e9bda8d29a8ba29a0502e3b0 (diff)
downloadastro-b236d88addc48d784bd60119fe45750dda900f16.tar.gz
astro-b236d88addc48d784bd60119fe45750dda900f16.tar.zst
astro-b236d88addc48d784bd60119fe45750dda900f16.zip
fix(create-astro): respect existing `package.json#scripts` (#8911)
Diffstat (limited to 'packages/create-astro/src')
-rw-r--r--packages/create-astro/src/actions/typescript.ts10
1 files changed, 3 insertions, 7 deletions
diff --git a/packages/create-astro/src/actions/typescript.ts b/packages/create-astro/src/actions/typescript.ts
index cc00f20e5..3be99e179 100644
--- a/packages/create-astro/src/actions/typescript.ts
+++ b/packages/create-astro/src/actions/typescript.ts
@@ -96,13 +96,9 @@ const FILES_TO_UPDATE = {
// in case of any other template already have astro checks defined, we don't want to override it
if (typeof buildScript === 'string' && !buildScript.includes('astro check')) {
- const newPackageJson = Object.assign(parsedPackageJson, {
- scripts: {
- build: 'astro check && ' + buildScript,
- },
- });
-
- await writeFile(file, JSON.stringify(newPackageJson, null, indent), 'utf-8');
+ // Mutate the existing object to avoid changing user-defined script order
+ parsedPackageJson.scripts.build = `astro check && ${buildScript}`;
+ await writeFile(file, JSON.stringify(parsedPackageJson, null, indent), 'utf-8');
}
} catch (err) {
// if there's no package.json (which is very unlikely), then do nothing