summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ADTC <send2adtc@gmail.com> 2025-02-24 17:44:56 +0800
committerGravatar GitHub <noreply@github.com> 2025-02-24 09:44:56 +0000
commit6012e061cdd07688be73d5d543ad3a055c373475 (patch)
tree5d9bbfd74905dd776a2c50fe517db99b450ff677
parent8810696ade059468b322e329b0573a07444e6889 (diff)
downloadastro-6012e061cdd07688be73d5d543ad3a055c373475.tar.gz
astro-6012e061cdd07688be73d5d543ad3a055c373475.tar.zst
astro-6012e061cdd07688be73d5d543ad3a055c373475.zip
Modify the template README file to reflect the correct package manager (#13257)
-rw-r--r--.changeset/slow-goats-eat.md5
-rw-r--r--packages/create-astro/src/actions/template.ts13
2 files changed, 18 insertions, 0 deletions
diff --git a/.changeset/slow-goats-eat.md b/.changeset/slow-goats-eat.md
new file mode 100644
index 000000000..d2729fcc6
--- /dev/null
+++ b/.changeset/slow-goats-eat.md
@@ -0,0 +1,5 @@
+---
+'create-astro': patch
+---
+
+Modify the template README file to reflect the correct package manager
diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts
index 512e1f921..6ac2e5be2 100644
--- a/packages/create-astro/src/actions/template.ts
+++ b/packages/create-astro/src/actions/template.ts
@@ -103,6 +103,19 @@ export default async function copyTemplate(tmpl: string, ctx: Context) {
cwd: ctx.cwd,
dir: '.',
});
+
+ // Modify the README file to reflect the correct package manager
+ if (ctx.packageManager !== 'npm') {
+ const readmePath = path.resolve(ctx.cwd, 'README.md');
+ const readme = fs.readFileSync(readmePath, 'utf8');
+
+ // `run` is removed since it's optional in other package managers
+ const updatedReadme = readme
+ .replace(/\bnpm run\b/g, ctx.packageManager)
+ .replace(/\bnpm\b/g, ctx.packageManager);
+
+ fs.writeFileSync(readmePath, updatedReadme);
+ }
} catch (err: any) {
// Only remove the directory if it's most likely created by us.
if (ctx.cwd !== '.' && ctx.cwd !== './' && !ctx.cwd.startsWith('../')) {