Skip to content

Commit

Permalink
fix: print notes straight to stdout (redwoodjs#6871)
Browse files Browse the repository at this point in the history
* fix: print notes straight to stdout

* Update packages/cli-helpers/src/auth/setupHelpers.ts

Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>

Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
  • Loading branch information
jtoar and Tobbe authored Nov 13, 2022
1 parent bb1d403 commit 61ec0fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 0 additions & 9 deletions packages/cli-helpers/src/auth/authTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,3 @@ export const installPackages = {
await execa('yarn', ['install'])
},
}

export const printNotes = <Renderer extends typeof ListrRenderer>(
notes: string[]
) => ({
title: 'One more thing...',
task: (_ctx: never, task: ListrTaskWrapper<never, Renderer>) => {
task.title = `One more thing...\n\n ${notes.join('\n ')}\n`
},
})
11 changes: 9 additions & 2 deletions packages/cli-helpers/src/auth/setupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
addWebPackages,
generateAuthApiFiles,
installPackages,
printNotes,
} from './authTasks'

/**
Expand Down Expand Up @@ -110,13 +109,21 @@ export const standardAuthHandler = async ({
addApiPackages(apiPackages),
installPackages,
extraTask,
notes ? printNotes(notes) : null,
notes && {
title: 'One more thing...',
task: () => {
// Can't console.log the notes here because of
// https://github.com/cenk1cenk2/listr2/issues/296
// So we do it after the tasks have all finished instead
},
},
].filter(truthy),
{ rendererOptions: { collapse: false } }
)

try {
await tasks.run()
notes && console.log(`\n ${notes.join('\n ')}\n`)
} catch (e) {
if (isErrorWithMessage(e)) {
errorTelemetry(process.argv, e.message)
Expand Down

0 comments on commit 61ec0fe

Please sign in to comment.