mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix behaviour regression in create-astro (#8634)
This commit is contained in:
parent
bd00ad776d
commit
b64dd45c0d
3 changed files with 17 additions and 6 deletions
5
.changeset/neat-islands-wink.md
Normal file
5
.changeset/neat-islands-wink.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
Fix `--yes` behaviour to prevent it overriding `--template`
|
|
@ -9,10 +9,11 @@ import { error, info, spinner, title } from '../messages.js';
|
|||
export async function template(
|
||||
ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit'>
|
||||
) {
|
||||
if (ctx.yes) {
|
||||
ctx.template = 'basics';
|
||||
if (!ctx.template && ctx.yes) ctx.template = 'basics';
|
||||
|
||||
if (ctx.template) {
|
||||
await info('tmpl', `Using ${color.reset(ctx.template)}${color.dim(' as project template')}`);
|
||||
} else if (!ctx.template) {
|
||||
} else {
|
||||
const { template: tmpl } = await ctx.prompt({
|
||||
name: 'template',
|
||||
type: 'select',
|
||||
|
@ -26,8 +27,6 @@ export async function template(
|
|||
],
|
||||
});
|
||||
ctx.template = tmpl;
|
||||
} else {
|
||||
await info('tmpl', `Using ${color.reset(ctx.template)}${color.dim(' as project template')}`);
|
||||
}
|
||||
|
||||
if (ctx.dryRun) {
|
||||
|
|
|
@ -33,4 +33,11 @@ describe('template', () => {
|
|||
|
||||
expect(fixture.hasMessage('Using blog as project template')).to.be.true;
|
||||
});
|
||||
|
||||
it('minimal (--yes)', async () => {
|
||||
const context = { template: 'minimal', cwd: '', dryRun: true, yes: true, prompt: () => {} };
|
||||
await template(context);
|
||||
|
||||
expect(fixture.hasMessage('Using minimal as project template')).to.be.true;
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue