Skip to content

Commit 727b2f8

Browse files
Refactor
1 parent 8ea041d commit 727b2f8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/commands/test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,10 @@ async function getPlatform(logsOpt) {
127127
const release = os.release()
128128
const cpuCore = os.cpus()[0]
129129
const isM1 = cpuCore.model.includes("Apple M1")
130-
const majorVersion = semver.major(release)
131-
let linuxVersion = ""
132-
if (type === 'Linux') linuxVersion = await getLinuxVersion()
130+
const majorVersion = (type === 'Linux') ? await getLinuxVersion() : semver.major(release)
133131

134132
if (logsOpt) {
135-
print.info(`OS type: ${type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${type === 'Linux' ? linuxVersion : majorVersion}\nCPU model: ${cpuCore.model}`)
133+
print.info(`OS type: ${type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${cpuCore.model}`)
136134
}
137135

138136
if (arch === 'x64' || (arch === 'arm64' && isM1)) {
@@ -146,12 +144,12 @@ async function getPlatform(logsOpt) {
146144
}
147145
return 'binary-macos-11'
148146
} else if (type === 'Linux') {
149-
if (linuxVersion === '18.04') {
147+
if (majorVersion === 18) {
150148
return 'binary-linux-18'
151-
} else if (linuxVersion == '20.04') {
149+
} else if (majorVersion == 20) {
152150
return 'binary-linux-20'
153151
} else {
154-
throw new Error(`Unsupported Linux Version: ${linuxVersion}`)
152+
throw new Error(`Unsupported Linux Version: ${majorVersion}`)
155153
}
156154
} else if (type === 'Windows_NT') {
157155
return 'binary-windows'
@@ -163,7 +161,8 @@ async function getPlatform(logsOpt) {
163161

164162
async function getLinuxVersion() {
165163
let version = await system.run("grep '^VERSION_ID' /etc/os-release", {trim: true})
166-
return version.replace(/[VERSION_ID=]|['"]+/g, '').trim()
164+
version = version.replace(/[VERSION_ID=]|['"]+/g, '')
165+
return parseInt(version)
167166
}
168167

169168
async function runDocker(datasource, opts) {

0 commit comments

Comments
 (0)