Skip to content

Commit e2812de

Browse files
committed
fix: Swap out chalk for ansi-color
1 parent 0953292 commit e2812de

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

lib/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const program = require('commander')
2-
const chalk = require('chalk')
2+
const colour = require('../lib/util/colour')
33
const actions = require('./actions')
44

55
require('../lib/util/enhanceErrorMessages')
@@ -12,21 +12,21 @@ function tymlyCli (argv) {
1212
program
1313
.command('init [blueprint-name]')
1414
.description('create a new Tymly blueprint')
15-
.action((cmd, options) => {
16-
actions.init(cmd, options)
15+
.action((blueprintName, options) => {
16+
actions.init(blueprintName, options)
1717
})
1818

1919
program
2020
.arguments('<command>')
2121
.action((cmd) => {
2222
program.outputHelp()
23-
console.log(`${chalk.red('Unknown command')} ${chalk.yellow(cmd)}.`)
23+
console.log(`${colour.red('Unknown command')} ${colour.yellow(cmd)}.`)
2424
console.log()
2525
})
2626

2727
program.on('--help', () => {
2828
console.log()
29-
console.log(`Run ${chalk.cyan(`tymly <command> --help`)} for detailed usage of given command.`)
29+
console.log(`Run ${colour.cyan(`tymly <command> --help`)} for detailed usage of given command.`)
3030
console.log()
3131
})
3232

lib/util/colour.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const color = require('ansi-color').set
2+
3+
console.log(color)
4+
5+
function c (colorName) {
6+
return text => color(text, colorName)
7+
}
8+
9+
module.exports = {
10+
red: c('red'),
11+
yellow: c('yellow'),
12+
cyan: c('cyan')
13+
}

lib/util/enhanceErrorMessages.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
const program = require('commander')
2-
const chalk = require('chalk')
2+
const colour = require('./colour')
33

44
function enhanceErrorMessages (methodName, log) {
55
program.Command.prototype[methodName] = function (...args) {
66
if (methodName === 'unknownOption' && this._allowUnknownOption) {
77
return
88
}
99
this.outputHelp()
10-
console.log(chalk.red(log(...args)))
10+
console.log(colour.red(log(...args)))
1111
console.log()
1212
}
1313
}
1414

1515
enhanceErrorMessages('missingArgument', argName => {
16-
return `\nMissing required argument ${chalk.yellow(`<${argName}>`)}.`
16+
return `\nMissing required argument ${colour.yellow(`<${argName}>`)}.`
1717
})
1818

1919
enhanceErrorMessages('unknownOption', optionName => {
20-
return `\nUnknown option ${chalk.yellow(optionName)}.`
20+
return `\nUnknown option ${colour.yellow(optionName)}.`
2121
})
2222

2323
enhanceErrorMessages('optionMissingArgument', (option, flag) => {
24-
return `Missing required argument for option ${chalk.yellow(option.flags)}` + (
25-
flag ? `, got ${chalk.yellow(flag)}` : ``
24+
return `Missing required argument for option ${colour.yellow(option.flags)}` + (
25+
flag ? `, got ${colour.yellow(flag)}` : ``
2626
)
2727
})
2828

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
"tymly": "bin/tymly-cli.js"
2424
},
2525
"dependencies": {
26-
"chalk": "2.4.2",
27-
"commander": "2.19.0"
26+
"@wmfs/tymly-scaffold": "1.0.0",
27+
"ansi-color": "0.2.1",
28+
"commander": "2.19.0",
29+
"enquirer": "2.3.0"
2830
},
2931
"devDependencies": {
3032
"@semantic-release/changelog": "3.0.1",

0 commit comments

Comments
 (0)