mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
trim project name of the user input (#8427)
* fix: remove duplicate import * project name should be trimed * update changeset
This commit is contained in:
parent
2272f8d3c4
commit
b81ff8fcef
3 changed files with 15 additions and 1 deletions
5
.changeset/eighty-gifts-speak.md
Normal file
5
.changeset/eighty-gifts-speak.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
trim project name of the user input
|
|
@ -31,7 +31,7 @@ export async function projectName(ctx: Pick<Context, 'cwd' | 'prompt' | 'project
|
|||
},
|
||||
});
|
||||
|
||||
ctx.cwd = name!;
|
||||
ctx.cwd = name!.trim();
|
||||
ctx.projectName = toValidName(name!);
|
||||
} else {
|
||||
let name = ctx.cwd;
|
||||
|
|
|
@ -62,6 +62,15 @@ describe('project name', () => {
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue