Skip to content

Commit

Permalink
fix: do not prompt on supplying template as an argument. (#1527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored Feb 25, 2021
1 parent c33d3f6 commit 977d59a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-ravens-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Do not prompt on supplying the template as an argument
10 changes: 5 additions & 5 deletions packages/cli/lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ const options = [
];

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

return [
// Required data
{
type: argv.template ? null : 'select',
type: repo ? null : 'select',
name: 'template',
message: 'Pick a template',
choices: templates,
Expand All @@ -96,12 +96,12 @@ function requestParams(argv, templates) {
message: 'Remote template to clone (user/repo#tag)',
},
{
type: argv.dest ? null : 'text',
type: dest ? null : 'text',
name: 'dest',
message: 'Directory to create the app',
},
{
type: prev => (!dirExists(cwd, prev || argv.dest) ? null : 'confirm'),
type: prev => (!dirExists(cwd, prev || dest) ? null : 'confirm'),
name: 'force',
message: 'The destination directory exists. Overwrite?',
initial: false,
Expand Down Expand Up @@ -211,7 +211,7 @@ async function command(repo, dest, argv) {
// Prompt if incomplete data
if (!repo || !dest) {
const templates = await fetchTemplates();
const questions = requestParams(argv, templates);
const questions = requestParams(repo, dest, argv, templates);
const onCancel = () => {
info('Aborting execution');
process.exit();
Expand Down

0 comments on commit 977d59a

Please sign in to comment.