@@ -127,12 +127,10 @@ async function getPlatform(logsOpt) {
127
127
const release = os . release ( )
128
128
const cpuCore = os . cpus ( ) [ 0 ]
129
129
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 )
133
131
134
132
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 } ` )
136
134
}
137
135
138
136
if ( arch === 'x64' || ( arch === 'arm64' && isM1 ) ) {
@@ -146,12 +144,12 @@ async function getPlatform(logsOpt) {
146
144
}
147
145
return 'binary-macos-11'
148
146
} else if ( type === 'Linux' ) {
149
- if ( linuxVersion === '18.04' ) {
147
+ if ( majorVersion === 18 ) {
150
148
return 'binary-linux-18'
151
- } else if ( linuxVersion == '20.04' ) {
149
+ } else if ( majorVersion == 20 ) {
152
150
return 'binary-linux-20'
153
151
} else {
154
- throw new Error ( `Unsupported Linux Version: ${ linuxVersion } ` )
152
+ throw new Error ( `Unsupported Linux Version: ${ majorVersion } ` )
155
153
}
156
154
} else if ( type === 'Windows_NT' ) {
157
155
return 'binary-windows'
@@ -163,7 +161,8 @@ async function getPlatform(logsOpt) {
163
161
164
162
async function getLinuxVersion ( ) {
165
163
let version = await system . run ( "grep '^VERSION_ID' /etc/os-release" , { trim : true } )
166
- return version . replace ( / [ V E R S I O N _ I D = ] | [ ' " ] + / g, '' ) . trim ( )
164
+ version = version . replace ( / [ V E R S I O N _ I D = ] | [ ' " ] + / g, '' )
165
+ return parseInt ( version )
167
166
}
168
167
169
168
async function runDocker ( datasource , opts ) {
0 commit comments