Skip to content

Commit a93bb18

Browse files
authored
fix benchmark-cmp-branch, remove chalk and inquirer (#473)
1 parent bcd1296 commit a93bb18

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ on:
1313
jobs:
1414
test:
1515
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
16-
with:
17-
auto-merge-exclude: 'chalk'

benchmark/bench-cmp-branch.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,35 @@
22

33
const { spawn } = require('child_process')
44

5-
const chalk = require('chalk')
6-
const inquirer = require('inquirer')
5+
const cliSelect = require('cli-select')
76
const simpleGit = require('simple-git')
87

98
const git = simpleGit(process.cwd())
109

1110
const COMMAND = 'npm run bench'
1211
const DEFAULT_BRANCH = 'master'
1312
const PERCENT_THRESHOLD = 5
13+
const greyColor = '\x1b[30m'
14+
const redColor = '\x1b[31m'
15+
const greenColor = '\x1b[32m'
16+
const resetColor = '\x1b[0m'
1417

1518
async function selectBranchName (message, branches) {
16-
const result = await inquirer.prompt([{
19+
console.log(message)
20+
const result = await cliSelect({
1721
type: 'list',
1822
name: 'branch',
19-
choices: branches,
20-
loop: false,
21-
pageSize: 20,
22-
message
23-
}])
24-
return result.branch
23+
values: branches
24+
})
25+
console.log(result.value)
26+
return result.value
2527
}
2628

2729
async function executeCommandOnBranch (command, branch) {
28-
console.log(chalk.grey(`Checking out "${branch}"`))
30+
console.log(`${greyColor}Checking out "${branch}"${resetColor}`)
2931
await git.checkout(branch)
3032

31-
console.log(chalk.grey(`Execute "${command}"`))
33+
console.log(`${greyColor}Execute "${command}"${resetColor}`)
3234
const childProcess = spawn(command, { stdio: 'pipe', shell: true })
3335

3436
let result = ''
@@ -74,9 +76,9 @@ function compareResults (featureBranch, mainBranch) {
7476
const message = alignedName + percentString.padStart(7, '.')
7577

7678
if (roundedPercent > PERCENT_THRESHOLD) {
77-
console.log(chalk.green(message))
79+
console.log(`${greenColor}${message}${resetColor}`)
7880
} else if (roundedPercent < -PERCENT_THRESHOLD) {
79-
console.log(chalk.red(message))
81+
console.log(`${redColor}${message}${resetColor}`)
8082
} else {
8183
console.log(message)
8284
}
@@ -110,5 +112,5 @@ function compareResults (featureBranch, mainBranch) {
110112
await git.checkout(currentBranch.commit)
111113
await git.checkout(currentBranch.name)
112114

113-
console.log(chalk.gray(`Back to ${currentBranch.name} ${currentBranch.commit}`))
115+
console.log(`${greyColor}Back to ${currentBranch.name} ${currentBranch.commit}${resetColor}`)
114116
})()

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
"devDependencies": {
3636
"@sinclair/typebox": "^0.23.3",
3737
"benchmark": "^2.1.4",
38-
"chalk": "^4.1.2",
38+
"cli-select": "^1.1.2",
3939
"compile-json-stringify": "^0.1.2",
40-
"inquirer": "^9.0.0",
4140
"is-my-json-valid": "^2.20.0",
4241
"luxon": "^2.4.0",
4342
"pre-commit": "^1.2.2",

0 commit comments

Comments
 (0)