diff --git a/cli/lib/exec/spawn.js b/cli/lib/exec/spawn.js index e49f0059cd1e..85a912b2f59f 100644 --- a/cli/lib/exec/spawn.js +++ b/cli/lib/exec/spawn.js @@ -1,5 +1,4 @@ const _ = require('lodash') -const os = require('os') const cp = require('child_process') const path = require('path') const Promise = require('bluebird') @@ -13,16 +12,12 @@ const { throwFormErrorText, errors } = require('../errors') const isXlibOrLibudevRe = /^(?:Xlib|libudev)/ const isHighSierraWarningRe = /\*\*\* WARNING/ -function isPlatform (platform) { - return os.platform() === platform -} - function needsStderrPiped (needsXvfb) { - return isPlatform('darwin') || (needsXvfb && isPlatform('linux')) + return util.isPlatform('darwin') || (needsXvfb && util.isPlatform('linux')) } function needsEverythingPipedDirectly () { - return isPlatform('win32') + return util.isPlatform('win32') } function getStdio (needsXvfb) { diff --git a/cli/lib/util.js b/cli/lib/util.js index 634bb4a85449..524ef7737cc0 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -15,6 +15,7 @@ const isInstalledGlobally = require('is-installed-globally') const pkg = require(path.join(__dirname, '..', 'package.json')) const logger = require('./logger') const debug = require('debug')('cypress:cli') +const compareVersions = require('compare-versions') const getosAsync = Promise.promisify(getos) @@ -67,6 +68,7 @@ const util = { .mapValues((value) => { // stringify to 1 or 0 return value ? '1' : '0' }) + .extend(util.getNode11WindowsFix()) // the value has to be falsy, '0' as a string not good enoughs .value() }, @@ -78,6 +80,14 @@ const util = { } }, + getNode11WindowsFix () { + if (compareVersions(util.getNodeVersion(), 'v11') >= 0 && util.isPlatform('win32')) { + return { + windowsHide: false, + } + } + }, + getEnvColors () { const sc = util.supportsColor() @@ -88,6 +98,14 @@ const util = { } }, + getNodeVersion () { + return process.version + }, + + isPlatform (platform) { + return os.platform() === platform + }, + isTty (fd) { return tty.isatty(fd) }, diff --git a/cli/package.json b/cli/package.json index 2905eaee7bc5..ff9b72cd851e 100644 --- a/cli/package.json +++ b/cli/package.json @@ -56,6 +56,7 @@ "check-more-types": "2.24.0", "commander": "2.11.0", "common-tags": "1.4.0", + "compare-versions": "3.4.0", "debug": "3.1.0", "execa": "0.10.0", "executable": "4.1.1", diff --git a/cli/test/lib/util_spec.js b/cli/test/lib/util_spec.js index 1687d5c9c212..dfc71681b9a6 100644 --- a/cli/test/lib/util_spec.js +++ b/cli/test/lib/util_spec.js @@ -191,6 +191,36 @@ describe('util', () => { DEBUG_COLORS: '0', }) }) + + context('.windowsHide', () => { + it('is false on windows with node 11', () => { + os.platform.returns('win32') + sinon.stub(process, 'version').value('v11.0.0') + expect(util.getEnvOverrides().windowsHide).to.be.false + }) + + it('is false on windows with node > 11', () => { + os.platform.returns('win32') + sinon.stub(process, 'version').value('v12.0.0') + expect(util.getEnvOverrides().windowsHide).to.be.false + }) + + it('is undefined on windows with node < 11', () => { + os.platform.returns('win32') + sinon.stub(process, 'version').value('v8.0.0') + expect(util.getEnvOverrides().windowsHide).to.be.undefined + + os.platform.returns('win32') + sinon.stub(process, 'version').value('v10.0.0') + expect(util.getEnvOverrides().windowsHide).to.be.undefined + }) + + it('is undefined on non-windows with node 11', () => { + os.platform.returns('darwin') + sinon.stub(process, 'version').value('v11.0.0') + expect(util.getEnvOverrides().windowsHide).to.be.undefined + }) + }) }) context('.getForceTty', () => {