Skip to content

Instantly share code, notes, and snippets.

View nbolton's full-sized avatar
🇺🇦

Nick Bolton nbolton

🇺🇦
View GitHub Profile
@nbolton
nbolton / unix.sh
Last active August 25, 2023 12:25
Scripts for fnm
# unix/bash (.sh)
export PATH="/path/to/fnm:$PATH"
eval "`fnm env`"
if [ -f ".nvmrc" ]
then
fnm use
else
if [ -f "../.nvmrc" ]
then
fnm use ..
@nbolton
nbolton / parse-version.ps1
Last active July 21, 2023 13:50
PowerShell function to parse version numbers with regex
function Get-Version-Number ([String]$versionText) {
# matches 1.2 or 1.2.3
$pattern = "(\d+)\.?(\d+)\.?((\d+)\.?)?"
$parts = [regex]::Matches($versionText, $pattern)
[hashtable]$version = @{}
if ($parts.Groups.Length -gt 0) {
$version.Major = [int]$parts.Groups[1].value
$version.Minor = [int]$parts.Groups[2].value
if ($parts.Groups.Length -gt 3) {