Skip to content

Commit 2834b04

Browse files
committed
🐛 fix(cli): use 'gray' instead of 'grey' in styleText calls (#2321)
Node.js util.styleText does not accept 'grey' as a format name. While util.inspect.colors defines 'grey' as a non-enumerable alias for 'gray', styleText validates against Object.keys(inspect.colors) which only includes enumerable properties — so 'grey' has never been a valid styleText format and throws ERR_INVALID_ARG_VALUE. (cherry picked from commit 59b58076016c5e5f09f16ab0395fed02e2ebb72e)
1 parent 535bf3a commit 2834b04

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

content

quartz/cli/handlers.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ export async function handleBuild(argv) {
309309
}
310310

311311
const result = await ctx.rebuild().catch((err) => {
312-
console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`)
313-
console.log(`Reason: ${chalk.grey(err)}`)
312+
console.error(`${styleText("red", "Couldn't parse Quartz configuration:")} ${fp}`)
313+
console.log(`Reason: ${styleText("gray", err)}`)
314314
process.exit(1)
315315
})
316316
release()
@@ -335,7 +335,7 @@ export async function handleBuild(argv) {
335335
clientRefresh()
336336
}
337337

338-
let clientRefresh = () => {}
338+
let clientRefresh = () => { }
339339
if (argv.serve) {
340340
const connections = []
341341
clientRefresh = () => connections.forEach((conn) => conn.send("rebuild"))
@@ -383,8 +383,10 @@ export async function handleBuild(argv) {
383383
})
384384
const status = res.statusCode
385385
const statusString =
386-
status >= 200 && status < 300 ? chalk.green(`[${status}]`) : chalk.red(`[${status}]`)
387-
console.log(statusString + chalk.grey(` ${argv.baseDir}${req.url}`))
386+
status >= 200 && status < 300
387+
? styleText("green", `[${status}]`)
388+
: styleText("red", `[${status}]`)
389+
console.log(statusString + styleText("gray", ` ${argv.baseDir}${req.url}`))
388390
release()
389391
}
390392

@@ -393,7 +395,10 @@ export async function handleBuild(argv) {
393395
res.writeHead(302, {
394396
Location: newFp,
395397
})
396-
console.log(chalk.yellow("[302]") + chalk.grey(` ${argv.baseDir}${req.url} -> ${newFp}`))
398+
console.log(
399+
styleText("yellow", "[302]") +
400+
styleText("gray", ` ${argv.baseDir}${req.url} -> ${newFp}`),
401+
)
397402
res.end()
398403
}
399404

@@ -467,7 +472,7 @@ export async function handleBuild(argv) {
467472
.on("change", () => build(clientRefresh))
468473
.on("unlink", () => build(clientRefresh))
469474

470-
console.log(chalk.grey("hint: exit with ctrl+c"))
475+
console.log(styleText("gray", "hint: exit with ctrl+c"))
471476
}
472477
}
473478

0 commit comments

Comments
 (0)