Created
January 3, 2022 02:01
-
-
Save maggiben/0cda51c16f3c1a1d1611556a109ccb51 to your computer and use it in GitHub Desktop.
Get Node Version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getNodeVersion(): { major: number; minor: number; patch: number } { | |
const version = process.version.match(/(\d+)\.(\d+)\.(\d+)/); | |
const [major, minor, patch] = ensureArray(version) | |
.slice(1) | |
.map((match) => parseInt(match as string, 10)); | |
return { | |
major, | |
minor, | |
patch, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment