UNPKG

kocha

Version:

Modern, simpler Mocha clone, no globals, lint friendly

48 lines (42 loc) 1.06 kB
'use strict'; var tty = require('tty' /** * Check if both stdio streams are associated with a tty. */ );var isatty = tty.isatty(1) && tty.isatty(2 /** * Expose term window size, with some defaults for when stderr is not a tty. */ );var window = { width: 75 }; if (isatty) { window.width = process.stdout.getWindowSize ? process.stdout.getWindowSize(1)[0] : tty.getWindowSize()[1]; } /** * Expose some basic cursor interactions that are common among reporters. */ var cursor = { hide: function hide() { isatty && process.stdout.write('\x1B[?25l'); }, show: function show() { isatty && process.stdout.write('\x1B[?25h'); }, deleteLine: function deleteLine() { isatty && process.stdout.write('\x1B[2K'); }, beginningOfLine: function beginningOfLine() { isatty && process.stdout.write('\x1B[0G'); }, CR: function CR() { if (isatty) { cursor.deleteLine(); cursor.beginningOfLine(); } else { process.stdout.write('\r'); } } }; module.exports = cursor; module.exports.window = window;