Skip to content

Commit

Permalink
refactor(script): compare only to the middle version when checking ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
Kinplemelon committed Apr 9, 2024
1 parent cf0c015 commit 025ff73
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/checkPackageVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
const packageJSON = require('../package.json')
const axios = require('axios')
const baseURL = process.env.HOST_URL || 'http://localhost:18083'
const packageVersion = packageJSON.version
const rawPackageVersion = packageJSON.version

const emqxVersionRegex = /^[ev](\d+\.\d+\.\d+)/
const packageVersionRegex = /^(\d+\.\d+)/
const matchPackageVersion = (packageVersion) => {
const matchRet = packageVersion.match(packageVersionRegex)
return matchRet ? matchRet[1] : ''
}

const emqxVersionRegex = /^[ev](\d+\.\d+)/
const matchEmqxVersion = (emqxVersion) => {
const matchRet = emqxVersion.match(emqxVersionRegex)
return matchRet ? matchRet[1] : ''
Expand All @@ -13,6 +19,7 @@ const matchEmqxVersion = (emqxVersion) => {
const check = async () => {
const { data } = await axios.get(`${baseURL}/api/v5/status`, { params: { format: 'json' } })
const { rel_vsn } = data
const packageVersion = matchPackageVersion(rawPackageVersion)
const emqxVersion = matchEmqxVersion(rel_vsn)
if (emqxVersion !== packageVersion) {
console.log('EMQX Version:', emqxVersion)
Expand Down

0 comments on commit 025ff73

Please sign in to comment.