From b81ff8fcefe6c30312d7b2050a63b1520d79b25f Mon Sep 17 00:00:00 2001 From: aswind7 Date: Wed, 6 Sep 2023 21:22:18 +0800 Subject: [PATCH] trim project name of the user input (#8427) * fix: remove duplicate import * project name should be trimed * update changeset --- .changeset/eighty-gifts-speak.md | 5 +++++ packages/create-astro/src/actions/project-name.ts | 2 +- packages/create-astro/test/project-name.test.js | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/eighty-gifts-speak.md diff --git a/.changeset/eighty-gifts-speak.md b/.changeset/eighty-gifts-speak.md new file mode 100644 index 000000000000..38f64ac002f4 --- /dev/null +++ b/.changeset/eighty-gifts-speak.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +trim project name of the user input diff --git a/packages/create-astro/src/actions/project-name.ts b/packages/create-astro/src/actions/project-name.ts index 943de91bf57c..b7099d9bbbed 100644 --- a/packages/create-astro/src/actions/project-name.ts +++ b/packages/create-astro/src/actions/project-name.ts @@ -31,7 +31,7 @@ export async function projectName(ctx: Pick { expect(context.projectName).to.eq('foobar'); }); + + it('blank space', async () => { + const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar ' }) }; + await projectName(context); + + expect(context.cwd).to.eq('foobar'); + expect(context.projectName).to.eq('foobar'); + }); + it('normalize', async () => { const context = { projectName: '', cwd: '', prompt: () => ({ name: 'Invalid Name' }) }; await projectName(context);