mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-05 23:00:03 -06:00
* temp 07/01/19 [skip ci] main lint files * use lint-staged scripts * fix all auto-fixable eslint errors * manually fix lint issues in files * temp 07/01/19 [skip ci] * bump eslint plugin versions, update circle.yml * [lint fix] remaining js files * update vscode/settings.json * add back stop-only * use stop-only for linting .onlys * fix verify_spec, build_spec * update json plugin * relint & apply corrections * fix appveyor.yml not cleansing env vars (very bad) * dont echo commit message in appveyor script * retry build & * re-add & upgrade lint-staged * update contributing docs * only let stop-only catch staged changes
63 lines
1.2 KiB
JavaScript
63 lines
1.2 KiB
JavaScript
const tty = require('tty')
|
|
const terminalSize = require('./terminal-size')
|
|
|
|
// polyfills node's getWindowSize
|
|
// by returning an array of columns/rows
|
|
function getWindowSize () {
|
|
const { columns, rows } = terminalSize.get()
|
|
|
|
return [columns, rows]
|
|
}
|
|
|
|
function patchStream (patched, name) {
|
|
const stream = process[name]
|
|
|
|
stream.isTTY = true
|
|
|
|
patched[stream.fd] = true
|
|
}
|
|
|
|
const override = () => {
|
|
const isatty = tty.isatty
|
|
|
|
const patched = {
|
|
0: false,
|
|
1: false,
|
|
2: false,
|
|
}
|
|
|
|
// polyfill in node's getWindowSize
|
|
// if it doesn't exist on stdout and stdin
|
|
// (if we are a piped process) or we are
|
|
// in windows on electron
|
|
;['stdout', 'stderr'].forEach((fn) => {
|
|
if (!process[fn].getWindowSize) {
|
|
process[fn].getWindowSize = getWindowSize
|
|
}
|
|
})
|
|
|
|
tty.isatty = function (fd) {
|
|
if (patched[fd]) {
|
|
// force stderr to return true
|
|
return true
|
|
}
|
|
|
|
// else pass through
|
|
return isatty.call(tty, fd)
|
|
}
|
|
|
|
if (process.env.FORCE_STDIN_TTY === '1') patchStream(patched, 'stdin')
|
|
|
|
if (process.env.FORCE_STDOUT_TTY === '1') patchStream(patched, 'stdout')
|
|
|
|
if (process.env.FORCE_STDERR_TTY === '1') patchStream(patched, 'stderr')
|
|
|
|
return
|
|
}
|
|
|
|
module.exports = {
|
|
override,
|
|
|
|
getWindowSize,
|
|
}
|