Skip to content

Deno module and cli tool for semantically sorting a set of version strings.

License

Notifications You must be signed in to change notification settings

Optum/semver-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d647309 Â· Apr 11, 2023

History

19 Commits
Sep 17, 2022
Sep 17, 2022
Oct 20, 2022
Sep 17, 2022
Sep 17, 2022
Sep 19, 2022
Sep 17, 2022
Sep 16, 2022
Sep 17, 2022
Apr 11, 2023
Sep 16, 2022
Oct 16, 2022
Sep 17, 2022
Sep 16, 2022

Repository files navigation

semver-sort 🦕

Sorts a set of version strings semantically

Usage

semver-sort can be used from code or from the cli directly.

api

import * as semver from "https://deno.land/[email protected]/semver/mod.ts";
import { semverSort } from "https://deno.land/x/[email protected]/mod.ts";

const sorted: { version: string; semver: SemVer }[] = semverSort(
  "1.12.0",
  "1.7",
  "2",
  "1.13.0",
);

// 2, 1.13.0, 1.12.0, 1.7

cli

Pass line delimited version strings as stdin to have them sorted.

cat test.txt | deno run "https://deno.land/x/[email protected]/main.ts"
install
deno install "https://deno.land/x/[email protected]/main.ts" -n semver-sort
cat test.txt | semver-sort
get the latest version
cat test.txt | semver-sort | head -n 1
get all versions except the latest
cat test.txt | semver-sort | tail -n +2

Contributing

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

Maintainers