File size: 579 Bytes
704e84f
96bdf6c
704e84f
96bdf6c
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const minimumNodeVersion = [22, 15, 0];

export const MIN_NODE_VERSION_RANGE = '>=22.15.0';

export function isSupportedNodeVersion(version = process.version) {
    const match = /^v?(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
    if (!match) return false;

    const current = match.slice(1, 4).map(Number);
    for (let index = 0; index < minimumNodeVersion.length; index += 1) {
        if (current[index] > minimumNodeVersion[index]) return true;
        if (current[index] < minimumNodeVersion[index]) return false;
    }
    return true;
}