Files
cypress/scripts/check-node-version.js
Emily Rohrbough e396956534 feat: remove windows 32-bit support (#18630)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Zach Bloomquist <git@chary.us>
2021-10-29 08:54:02 -05:00

48 lines
1.3 KiB
JavaScript

const os = require('os')
const assert = require('assert')
// TODO make this check a 3rd party little tool
const isWindows = () => {
return os.platform() === 'win32'
}
// if we're windows + in appveyor...
if (isWindows() && process.env.APPVEYOR) {
// check to ensure that the cpuArch + nodeArch are in sync
const cpuArch = process.env.Platform
const nodeArch = os.arch()
const getErrMsg = (expectedArch) => {
return `Appveyor CPU arch is set to: '${cpuArch}' but the node version that is being used is running: '${nodeArch}'. Expected it to equal: '${expectedArch}'`
}
assert.equal(
os.arch(),
'x64',
getErrMsg('x64'),
)
}
// we want to ensure we are building using the same major version
// as the one specified in ../.node-version file
const read = require('fs').readFileSync
const join = require('path').join
const nodeVersionNeededString = read(
join(__dirname, '..', '.node-version'),
'utf8',
)
const nodeVersionNeeded = nodeVersionNeededString.split('.')
const nodeVersion = process.versions.node.split('.')
// check just major version for now
if (nodeVersionNeeded[0] !== nodeVersion[0]) {
/* eslint-disable no-console */
console.error('🛑 .node-version specified %s', nodeVersionNeededString)
console.error('but current Node is %s', process.versions.node)
/* eslint-enable no-console */
process.exit(1)
}