fix: move from getos to systeminformation to fix OS distro/release info (#32283)

* fix: move from getos to systeminformation

* add changelog entry

* remove extraneous package that isn't used

* update changelog
This commit is contained in:
Jennifer Shehane
2025-08-27 09:52:48 -04:00
committed by GitHub
parent fa0b716eb7
commit ab2004bbde
7 changed files with 59 additions and 43 deletions
+1
View File
@@ -5,6 +5,7 @@ _Released 08/26/2025 (PENDING)_
**Bugfixes:**
- Fixed an issue where OS distributions and releases were sometimes not properly populated for Module API results and Cloud recordings. Fixes [#30533](https://github.com/cypress-io/cypress/issues/30533). Addressed in [#32283](https://github.com/cypress-io/cypress/pull/32283).
- Fixed an issue where the open Studio button would incorrectly show for component tests. Addressed in [#32315](https://github.com/cypress-io/cypress/pull/32315).
- Fixed an issue where the TypeScript compiler wasn't being resolved correctly when `@cypress/webpack-batteries-included-preprocessor` was used as a standalone package. Fixes [#32338](https://github.com/cypress-io/cypress/issues/32338).
+10 -13
View File
@@ -9,7 +9,7 @@ const tty = require('tty')
const path = require('path')
const isCi = require('ci-info').isCI
const execa = require('execa')
const getos = require('getos')
const si = require('systeminformation')
const chalk = require('chalk')
const Promise = require('bluebird')
const cachedir = require('cachedir')
@@ -26,8 +26,6 @@ const pkg = require(path.join(__dirname, '..', 'package.json'))
const issuesUrl = 'https://github.com/cypress-io/cypress/issues'
const getosAsync = Promise.promisify(getos)
/**
* Returns SHA512 of a file
*/
@@ -411,17 +409,16 @@ const util = {
getOsVersionAsync () {
return Promise.try(() => {
if (isLinux()) {
return getosAsync()
.then((osInfo) => {
return [osInfo.dist, osInfo.release].join(' - ')
})
.catch(() => {
return os.release()
})
}
return si.osInfo()
.then((osInfo) => {
if (osInfo.distro && osInfo.release) {
return `${osInfo.distro} - ${osInfo.release}`
}
return os.release()
return os.release()
}).catch(() => {
return os.release()
})
})
},
+1 -1
View File
@@ -45,7 +45,6 @@
"extract-zip": "2.0.1",
"figures": "^3.2.0",
"fs-extra": "^9.1.0",
"getos": "^3.2.1",
"hasha": "5.2.2",
"is-installed-globally": "~0.4.0",
"lazy-ass": "^1.6.0",
@@ -60,6 +59,7 @@
"request-progress": "^3.0.0",
"semver": "^7.7.1",
"supports-color": "^8.1.1",
"systeminformation": "5.27.7",
"tmp": "~0.2.4",
"tree-kill": "1.2.2",
"untildify": "^4.0.0",
+35 -9
View File
@@ -389,28 +389,54 @@ describe('util', () => {
describe('.getOsVersionAsync', () => {
let util
let getos = sinon.stub().resolves(['distro-release'])
let systeminformation = {
osInfo: sinon.stub(),
}
beforeEach(() => {
util = proxyquire(`${lib}/util`, { getos })
util = proxyquire(`${lib}/util`, { systeminformation })
})
it('calls os.release on non-linux', () => {
it('calls os.release when systeminformation fails', () => {
os.platform.returns('darwin')
os.release.returns('some-release')
util.getOsVersionAsync()
systeminformation.osInfo.rejects(new Error('systeminformation failed'))
return util.getOsVersionAsync()
.then(() => {
expect(os.release).to.be.called
expect(getos).to.not.be.called
expect(systeminformation.osInfo).to.be.called
})
})
it('NOT calls os.release on linux', () => {
it('uses systeminformation when it succeeds', () => {
os.platform.returns('linux')
util.getOsVersionAsync()
.then(() => {
systeminformation.osInfo.resolves({
distro: 'Ubuntu',
release: '22.04',
})
return util.getOsVersionAsync()
.then((result) => {
expect(result).to.equal('Ubuntu - 22.04')
expect(systeminformation.osInfo).to.be.called
// os.release should not be called when systeminformation succeeds
expect(os.release).to.not.be.called
expect(getos).to.be.called
})
})
it('falls back to os.release when systeminformation returns incomplete data', () => {
os.platform.returns('linux')
os.release.returns('5.15.0')
systeminformation.osInfo.resolves({
distro: 'Ubuntu',
// missing release property
})
return util.getOsVersionAsync()
.then(() => {
expect(systeminformation.osInfo).to.be.called
expect(os.release).to.be.called
})
})
})
+10 -10
View File
@@ -1,19 +1,19 @@
const os = require('os')
const Promise = require('bluebird')
const getos = Promise.promisify(require('getos'))
const si = require('systeminformation')
const getOsVersion = () => {
return Promise.try(() => {
if (os.platform() === 'linux') {
return getos()
.then((obj) => {
return [obj.dist, obj.release].join(' - ')
}).catch(() => {
return os.release()
})
}
return si.osInfo()
.then((osInfo) => {
if (osInfo.distro && osInfo.release) {
return `${osInfo.distro} - ${osInfo.release}`
}
return os.release()
return os.release()
}).catch(() => {
return os.release()
})
})
}
-1
View File
@@ -80,7 +80,6 @@
"fs-extra": "9.1.0",
"geckodriver": "5.0.0",
"get-port": "5.1.1",
"getos": "3.2.1",
"glob": "7.1.3",
"graceful-fs": "4.2.9",
"http-proxy": "1.18.1",
+2 -9
View File
@@ -10760,7 +10760,7 @@ async-settle@^1.0.0:
dependencies:
async-done "^1.2.2"
async@>=0.2.9, async@^3.2.0, async@^3.2.3, async@^3.2.4:
async@>=0.2.9, async@^3.2.3, async@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c"
integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==
@@ -17738,13 +17738,6 @@ getenv@1.0.0, getenv@^1.0.0:
resolved "https://registry.yarnpkg.com/getenv/-/getenv-1.0.0.tgz#874f2e7544fbca53c7a4738f37de8605c3fcfc31"
integrity sha512-7yetJWqbS9sbn0vIfliPsFgoXMKn/YMF+Wuiog97x+urnSRRRZ7xB+uVkwGKzRgq9CDFfMQnE9ruL5DHv9c6Xg==
getos@3.2.1, getos@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5"
integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==
dependencies:
async "^3.2.0"
getpass@^0.1.1:
version "0.1.7"
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -30145,7 +30138,7 @@ syntax-error@1.4.0:
dependencies:
acorn-node "^1.2.0"
systeminformation@^5.27.7:
systeminformation@5.27.7, systeminformation@^5.27.7:
version "5.27.7"
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-5.27.7.tgz#4dc9d436419948cd5e5f076779a1298220d19a72"
integrity sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==