Skip to content

Commit

Permalink
Issue 21316 windows node11 (#2699) (fixes #2667)
Browse files Browse the repository at this point in the history
* release 1.0.3 [skip ci]

* release 2.0.0 [skip ci]

* Add a comment to Issue Template directing questions to be asked in chat. [skip ci]

* release 3.1.0 [skip ci]

* add fix for windows + node11

* add getNode11WindowsFix to the utils

* formatting

* do not convert to the windowsHide to string

* add unit tests

* add unit tests

* add unit tests

* Revert "formatting"

This reverts commit 9ecd31b.

* don't ask to commit package.json version

* release 3.1.1 [skip ci]

* move isPlatform into cli/util

* fix version comparison

* revert accidental merge from master
  • Loading branch information
Zoltan Erdos authored and chrisbreiding committed Nov 13, 2018
1 parent 18af4fe commit 54ce93b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cli/lib/exec/spawn.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const _ = require('lodash')
const os = require('os')
const cp = require('child_process')
const path = require('path')
const Promise = require('bluebird')
Expand All @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
},

Expand All @@ -78,6 +80,14 @@ const util = {
}
},

getNode11WindowsFix () {
if (compareVersions(util.getNodeVersion(), 'v11') >= 0 && util.isPlatform('win32')) {
return {
windowsHide: false,
}
}
},

getEnvColors () {
const sc = util.supportsColor()

Expand All @@ -88,6 +98,14 @@ const util = {
}
},

getNodeVersion () {
return process.version
},

isPlatform (platform) {
return os.platform() === platform
},

isTty (fd) {
return tty.isatty(fd)
},
Expand Down
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 30 additions & 0 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 54ce93b

Please sign in to comment.