Skip to content

Commit

Permalink
fix ansi colour issue in output #66
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Jun 11, 2024
1 parent be23854 commit 22b0a34
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 1,192 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [18, 20, 21]
node-version: [18, 20, 22]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions lib/cli-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ async function usageSections (allOptionDefinitions, plugins) {
header: 'Replace chain',
content: plugins.length
? plugins.map(p => ({
name: '↓ ' + p.constructor.name,
desc: p.description && p.description()
}))
name: '↓ ' + p.constructor.name,
desc: p.description && p.description()
}))
: '{italic Replace chain empty, supply one or more plugins using --chain.}'
}
]
Expand Down
12 changes: 8 additions & 4 deletions lib/view/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ class DefaultView {
this.log()
}

logResult (result, options = {}) {
createResultLine (result) {
const tick = process.platform === 'win32' ? '√' : '✔︎'
const cross = process.platform === 'win32' ? '×' : '✖'
const symbol = chalk`{${result.renamed ? 'green' : 'red'} ${result.renamed ? tick : cross}}`
const symbol = chalk[result.renamed ? 'green' : 'red'](result.renamed ? tick : cross)
const desc = result.from + (result.renamed ? chalk.bold(' → ') + result.to : '')
const errDesc = result.error ? chalk`({red ${result.error}})` : ''
const errDesc = result.error ? `(${chalk.red(result.error)})` : ''
return `${symbol} ${desc} ${errDesc}`
}

logResult (result, options = {}) {
if (result.renamed || options.verbose) {
this.log(chalk`${symbol} ${desc} ${errDesc}`)
this.log(this.createResultLine(result))
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/view/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DiffView extends DefaultView {
logResult (result, options = {}) {
const tick = process.platform === 'win32' ? '√' : '✔︎'
const cross = process.platform === 'win32' ? '×' : '✖'
const symbol = chalk`{${result.renamed ? 'green' : 'red'} ${result.renamed ? tick : cross}}`
const symbol = chalk[result.renamed ? 'green' : 'red'](result.renamed ? tick : cross)

const data = []
if (result.renamed) {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/long.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LongView extends DefaultView {
logResult (result, options = {}) {
const tick = process.platform === 'win32' ? '√' : '✔︎'
const cross = process.platform === 'win32' ? '×' : '✖'
const symbol = chalk`{${result.renamed ? 'green' : 'red'} ${result.renamed ? tick : cross}}`
const symbol = chalk[result.renamed ? 'green' : 'red'](result.renamed ? tick : cross)

if (options.verbose) {
this.log(`${'Renamed:'.padEnd(8)} ${symbol}`)
Expand Down
Loading

0 comments on commit 22b0a34

Please sign in to comment.