karaoke(str, frame) { const chars = (frame % (str.length + 20)) - 10; if (chars < 0) { return chalk.white(str); } return chalk.rgb(255, 187, 0).bold(str.substr(0, chars)) + chalk.white(str.substr(chars)); }
getException() { const err = new AssertionFailedError(this.params, '{{customMessage}}expected {{subject}} {{type}}'); err.cliMessage = () => { const msg = err.template .replace('{{subject}}', output.colors.bold('{{subject}}')); return template(msg, this.params); }; return err; }
/** * @param {Mocha.Test} test */ skipped(test) { print(` ${colors.yellow.bold('S')} ${test.title}`); }
(async () => { const withYarn = await hasYarn() const margin = chalk.bgGreen(' ') const command = withYarn ? `yarn global add ${pkg.name}` : `npm i -g ${pkg.name}` console.log() console.log(`${margin} Update available: ${chalk.bold(notifier.update.latest)}`) console.log(`${margin} Run ${chalk.cyan(command)} to update`) console.log() })()
handler(ctx) { return this.Promise.reject(new MoleculerError("Unable to book flight!")); this.logger.info(kleur.cyan().bold("Flight is booked.")); return { id: 2, number: "SQ318", from: "SIN", to: "LHR" }; }
getColor(span) { let c = kleur.bold; if (span.tags.fromCache) c = c().yellow; if (span.tags.remoteCall) c = c().cyan; if (span.duration == null) c = c().grey; if (span.error) c = c().red; return c; }
fs.readdir("./icons", function (err, files) { extract(files); if (!fs.existsSync("./dist")) { fs.mkdirSync("./dist"); } fs.writeFile('./dist/icons.json', JSON.stringify(svgObject), (err) => { if (err) throw err; console.log(chalk.whiteBright.bgBlack.bold("Created [JSON] for SVG Icons !! ")); }); });
getFailedNegation() { this.params.type = 'not to include'; const err = this.getException(); const pattern = new RegExp(`^.*?\n?^.*?\n?^.*?${escapeRegExp(this.params.needle)}.*?$\n?.*$\n?.*$`, 'm'); const matched = this.params.haystack.match(pattern); if (!matched) return err; err.actual = matched[0].replace(this.params.needle, output.colors.bold(this.params.needle)); err.actual = `------\n${err.actual}\n------`; return err; }
const formatPrettyUrl = (hostname, port, pathname = '/') => { if (isUnspecifiedHost(hostname)) hostname = 'localhost' return url.format({ protocol: 'http', hostname, port: chalk.bold(port), pathname }) }
methodsOfObject(helper).forEach((action) => { const params = getParamsToString(helper[action]); actions[action] = 1; output.print(` ${output.colors.grey(name)} I.${output.colors.bold(action)}(${params})`); });
async handler(ctx) { try { const car = await ctx.call("cars.reserve"); const hotel = await ctx.call("hotels.book"); const flight = await ctx.call("flights.book"); this.logger.info(kleur.green().bold("Trip is created successfully: "), { car, flight, hotel }); } catch(err) { this.logger.error(kleur.red().bold("Trip couldn't be created. Reason: "), err.message); throw err; } }
/** * @param {Mocha.Test} test */ failed(test) { print(` ${colors.red.bold(`${figures.cross} FAILED`)} ${colors.grey(`in ${test.duration}ms`)}`); print(); }
/** * @param {Mocha.Test} test */ started(test) { print(` ${colors.magenta.bold(test.title)}`); }
(async () => { const withYarn = await hasYarn() const margin = chalk.bgGreen(' ') const command = withYarn ? `yarn global add ${pkg.name}` : `npm i -g ${pkg.name}` console.log() console.log(`${margin} Update available: ${chalk.bold(notifier.update.latest)}`) console.log(`${margin} Run ${chalk.cyan(command)} to update`) console.log() })()