Skip to content

Commit

Permalink
Merge pull request #480 from nobkd/win-enable-color
Browse files Browse the repository at this point in the history
feat: enable colored help text on windows, support `NO_COLOR` env var
  • Loading branch information
tipiirai authored Feb 12, 2025
2 parents 18ee0bf + b3f964c commit 62626d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/nuekit/src/cli-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function formatLine(line) {
}

export function getHelp() {
return !process.env.TERM ? HELP : HELP.split('\n').map(line => {
return HELP.split('\n').map(line => {
return line[0] === ' ' ? formatLine(line) : line
}).join('\n')
}
12 changes: 5 additions & 7 deletions packages/nuekit/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ log.error = function(msg, extra = "") {
console.log(colors.red('!!'), msg, extra)
}

function getColorFunctions() {
// console colors
export const colors = function() {
const codes = { red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, gray: 90 }
const fns = {}
const noColor = process.env.NO_COLOR || !(process.env.TERM || process.platform == 'win32')

for (const key in codes) {
fns[key] = msg => `\u001b[${codes[key]}m${msg}\u001b[39m`
fns[key] = msg => noColor ? msg : `\u001b[${codes[key]}m${msg}\u001b[39m`
}
return fns
}

// console colors
export const colors = getColorFunctions()

}()

// returns { url, dir, slug, appdir }
export function parsePathParts(path) {
Expand Down

0 comments on commit 62626d0

Please sign in to comment.