Skip to content

Commit

Permalink
Add default path value to page builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterp committed Feb 13, 2020
1 parent a0ec49f commit 02dce70
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/cli/src/commands/generate/commands/page.js
Expand Up @@ -24,22 +24,25 @@ export const files = ({ name, ...rest }) => {

export const routes = ({ name, path }) => {
return [
`<Route path="${path ?? `/${paramCase(name)}`}" page={${pascalcase(
`<Route path="${path}" page={${pascalcase(name)}Page} name="${camelcase(
name
)}Page} name="${camelcase(name)}" />`,
)}" />`,
]
}

export const command = 'page <name> [path]'
export const desc = 'Generates a page component.'
export const handler = async ({ name, path }) => {
export const builder = { force: { type: 'boolean', default: false } }

export const handler = async ({ name, path, force }) => {
path = path ?? `/${paramCase(name)}`
const tasks = new Listr(
[
{
title: 'Generating page files...',
task: async () => {
const f = await files({ name, path })
return writeFilesTask(f)
return writeFilesTask(f, { overwriteExisting: force })
},
},
{
Expand Down

0 comments on commit 02dce70

Please sign in to comment.