Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not prompt on supplying template as an argument. #1527

Merged
merged 4 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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