Files
cypress/cli/lib/exec/xvfb.js
Brian Mann d54156e2f2 cli, fixes #921, #1113, #1126, #1127, make DEBUG logs work, show error when xvfb exits with status code 1, force tty in linux, handle colors in windows, enable logging cypress:xvfb stderr
* cli: fixes #838 start cypress in dev by routing through the CLI

- matches how we run in production better to keep parity and consistency

* cli: add coerceFalse for clarity

* cli: add global flag, update to work with windows

* server: bring into parity with root scripts

* cli: just execute start script directly to work with windows

* cli: if colors are supported then force them via env vars

- this fixes windows not displaying colors from electron because by
default isTTY is false (due to electron)

* cli: fixes #921 don't ignore stderr, inherit stdio on everything except when linux + xvfb

- filter out stderr messages coming from Xlib or libudev (from xvfb)

* cli, server: force stderr tty so that normalize tty behavior when piping

* server: drop in supports color so debug outputs more colors!

* server: remove empty line

* root: refer to cypress not monorepo

* cli: make util.supportsColor return boolean

* cl: add tests around spawn behavior with forcing colors, tty, and stdio configuration

* cli: handle xvfb onStderrData callback to output debug information

* cli: handle non zero exit code error from xvfb with special message
2017-12-24 19:03:57 -05:00

55 lines
1.2 KiB
JavaScript

const os = require('os')
const Promise = require('bluebird')
const Xvfb = require('@cypress/xvfb')
const R = require('ramda')
const debug = require('debug')('cypress:cli')
const debugXvfb = require('debug')('cypress:xvfb')
const { throwFormErrorText, errors } = require('../errors')
const xvfb = Promise.promisifyAll(new Xvfb({
onStderrData (data) {
if (debugXvfb.enabled) {
debugXvfb(data.toString())
}
},
}))
module.exports = {
_debugXvfb: debugXvfb, // expose for testing
_xvfb: xvfb, // expose for testing
start () {
debug('Starting XVFB')
return xvfb.startAsync()
.catch({ nonZeroExitCode: true }, throwFormErrorText(errors.nonZeroExitCodeXvfb))
.catch((err) => {
if (err.known) {
throw err
}
return throwFormErrorText(errors.missingXvfb)(err)
})
},
stop () {
debug('Stopping XVFB')
return xvfb.stopAsync()
},
isNeeded () {
return os.platform() === 'linux' && !process.env.DISPLAY
},
// async method, resolved with Boolean
verify () {
return xvfb.startAsync()
.then(R.T)
.catch((err) => {
debug('Could not verify xvfb: %s', err.message)
return false
})
.finally(xvfb.stopAsync)
},
}