Skip to content

Commit 977d59a

Browse files
fix: do not prompt on supplying template as an argument. (#1527)
1 parent c33d3f6 commit 977d59a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.changeset/tame-ravens-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-cli': patch
3+
---
4+
5+
Do not prompt on supplying the template as an argument

packages/cli/lib/commands/create.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ const options = [
7878
];
7979

8080
// Formulate Questions if `create` args are missing
81-
function requestParams(argv, templates) {
81+
function requestParams(repo, dest, argv, templates) {
8282
const cwd = resolve(argv.cwd);
8383

8484
return [
8585
// Required data
8686
{
87-
type: argv.template ? null : 'select',
87+
type: repo ? null : 'select',
8888
name: 'template',
8989
message: 'Pick a template',
9090
choices: templates,
@@ -96,12 +96,12 @@ function requestParams(argv, templates) {
9696
message: 'Remote template to clone (user/repo#tag)',
9797
},
9898
{
99-
type: argv.dest ? null : 'text',
99+
type: dest ? null : 'text',
100100
name: 'dest',
101101
message: 'Directory to create the app',
102102
},
103103
{
104-
type: prev => (!dirExists(cwd, prev || argv.dest) ? null : 'confirm'),
104+
type: prev => (!dirExists(cwd, prev || dest) ? null : 'confirm'),
105105
name: 'force',
106106
message: 'The destination directory exists. Overwrite?',
107107
initial: false,
@@ -211,7 +211,7 @@ async function command(repo, dest, argv) {
211211
// Prompt if incomplete data
212212
if (!repo || !dest) {
213213
const templates = await fetchTemplates();
214-
const questions = requestParams(argv, templates);
214+
const questions = requestParams(repo, dest, argv, templates);
215215
const onCancel = () => {
216216
info('Aborting execution');
217217
process.exit();

0 commit comments

Comments
 (0)