function getColor(type) { switch(type) { case "fatal": return kleur.red().inverse; case "error": return kleur.red; case "warn": return kleur.yellow; case "debug": return kleur.magenta; case "trace": return kleur.gray; default: return kleur.green; } }
set value(v) { if (!v && v !== 0) { this.placeholder = true; this.rendered = color.gray(this.transform.render(`${this.initial}`)); this._value = ``; } else { this.placeholder = false; this.rendered = this.transform.render(`${round(v, this.round)}`); this._value = round(v, this.round); } this.fire(); }
/** * Prints a message to the log. * * @param {Object} unit The unit the message belongs to. * @param {string} message The message to print. */ function printLogMessage(unit, message) { const prompt = chalk.gray.dim('>'); const logMessage = getUnitStyle(unit)(`${unit.name} ${message}`); printLine(`${prompt} ${logMessage}`); }
test('prints log message with dimmed gray prompt', () => { const unitStyle = jest.fn(string => string); getUnitStyle.mockReturnValue(unitStyle); const unit = { name: 'Joe' }; const prompt = `${style.gray.open}${style.dim.open}>${style.dim.close}${ style.gray.close }`; printLogMessage(unit, 'is awesome!'); expect(getUnitStyle).toHaveBeenCalledWith(unit); expect(unitStyle).toHaveBeenCalledWith('Joe is awesome!'); expect(printLine).toHaveBeenCalledWith(`${prompt} Joe is awesome!`); });
indicator(state, choice) { if (choice.enabled) { return colors.cyan(state.symbols.radio.on); } return colors.gray(state.symbols.radio.off); }
set value(v) { if (!v && this.initial) { this.placeholder = true; this.rendered = color.gray(this.transform.render(this.initial)); } else { this.placeholder = false; this.rendered = this.transform.render(v); } this._value = v; this.fire(); }
setInterval(() => { const pre = lineBreak(2) + spacing(2) + chalk.gray.dim(spinner.frame()); if (!data.downloadSpeed) { logUpdate(pre + lineBreak(2)); return; } logUpdate(pre + speed()); }, 50);
indicator(state, choice) { if (choice.enabled) { return colors.red(state.symbols.heart); } return colors.dim.gray(state.symbols.heart); }
/** * Prints a separator row. */ function printSeparator() { printRow('', { padding: chalk.gray.dim('~'), }); }
/** * Prints a message to the log. * * @param {Object} unit The unit the message belongs to. * @param {string} message The message to print. */ function printLogMessage(unit, message) { const prompt = chalk.gray.dim('>'); const logMessage = getUnitStyle(unit)(`${unit.name} ${message}`); printLine(`${prompt} ${logMessage}`); }
/** * Prints a separator row. */ function printSeparator() { printRow('', { padding: chalk.gray.dim('~'), }); }
test('prints log message with dimmed gray prompt', () => { const unitStyle = jest.fn(string => string); getUnitStyle.mockReturnValue(unitStyle); const unit = { name: 'Joe' }; const prompt = `${style.gray.open}${style.dim.open}>${style.dim.close}${ style.gray.close }`; printLogMessage(unit, 'is awesome!'); expect(getUnitStyle).toHaveBeenCalledWith(unit); expect(unitStyle).toHaveBeenCalledWith('Joe is awesome!'); expect(printLine).toHaveBeenCalledWith(`${prompt} Joe is awesome!`); });