Skip to content

Commit

Permalink
feat: simpler and more intuitive api
Browse files Browse the repository at this point in the history
  • Loading branch information
skoshx committed Jul 26, 2024
1 parent 6cc14c2 commit 487d1c8
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 258 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8",
"turbo": "^1.10.6",
"type-fest": "^4.23.0",
"typescript": "5",
"unbuild": "^1.2.1",
"vite": "^4.3.9",
"vitest": "^0.32.2"
},
"packageManager": "[email protected]",
"dependencies": {
"typescript": "5"
}
"packageManager": "[email protected]"
}
26 changes: 21 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/formatters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Formatter } from './types'

export const textFormatter: Formatter = (logParts) => {
const events = logParts.filter(({ type }) => type === 'event')
const explanations = logParts.filter(({ type }) => type === 'explanation')
const solutions = logParts.filter(({ type }) => type === 'solution')

const capitalize = (input: string) => `${input.charAt(0).toUpperCase()}${input.slice(1)}`

const logMessageParts = [
capitalize(events.map(({ message }) => message).join(' and ')),
' because ',
explanations.map(({ message }) => message).join(' and '),
'.',
'\n',
'\n',
'Possible solutions:\n',
solutions.map(({ message }, solutionIndex) => `${solutionIndex + 1}) ${message}`)
]
return logMessageParts.join('')
}
Loading

0 comments on commit 487d1c8

Please sign in to comment.