fix: Handle nullish coalescing operator

This commit is contained in:
Felix Rieseberg 2024-10-07 11:27:39 -04:00
parent 35a3f2d037
commit f2d38f10c0
2 changed files with 5 additions and 5 deletions

View file

@ -78,7 +78,7 @@ async function run () {
} }
try { try {
const args = await prog.commands[command.name](command.args) ?? [] const args = await prog.commands[command.name](command.args) || []
if (command.name === 'list') { if (command.name === 'list') {
if (args.length) { if (args.length) {

View file

@ -89,15 +89,15 @@ class Logger {
} }
get level () { get level () {
return this.#levels.get(this.#level) ?? null return this.#levels.get(this.#level) || null
} }
set level (level) { set level (level) {
this.#level = this.#levels.get(level)?.id ?? null this.#level = this.#levels.get(level)?.id || null
} }
isVisible (level) { isVisible (level) {
return this.level?.index <= this.#levels.get(level)?.index ?? -1 return this.level?.index <= this.#levels.get(level)?.index || -1
} }
#onLog (...args) { #onLog (...args) {
@ -144,7 +144,7 @@ class Logger {
const prefixParts = [ const prefixParts = [
this.#color('gyp', { fg: 'white', bg: 'black' }), this.#color('gyp', { fg: 'white', bg: 'black' }),
this.#color(level.display ?? level.id, level.style) this.#color(level.display || level.id, level.style)
] ]
if (msgPrefix) { if (msgPrefix) {
prefixParts.push(this.#color(msgPrefix, { fg: 'magenta' })) prefixParts.push(this.#color(msgPrefix, { fg: 'magenta' }))