-
Notifications
You must be signed in to change notification settings - Fork 1
/
ver_check.js
28 lines (25 loc) · 964 Bytes
/
ver_check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const semver = require('semver')
const gantreeLib = require('gantree-lib')
const package = require('./package')
const realLibVersion = gantreeLib.version
const requiredLibVersion = package.dependencies['gantree-lib']
const libVersionSatisfactory = semver.satisfies(
realLibVersion,
requiredLibVersion
)
const red = '\x1b[31m'
const yellow = '\x1b[33m'
if (libVersionSatisfactory !== true) {
console.error(
`gantree-lib version doesn't satisfy semvar pattern in dependencies (pattern: ${requiredLibVersion}, local version: ${realLibVersion})`
)
console.log(
`${red}issue: gantree-lib version doesn't satisfy semvar pattern in dependencies (pattern: ${requiredLibVersion}, local version: ${realLibVersion})`
)
console.log(`${yellow}(lib) real version: ${realLibVersion}`)
console.log(`${yellow}(lib) required version: ${requiredLibVersion}`)
process.exit(1)
} else {
console.log('Library version satisfied.')
process.exit(0)
}