Simple version ensurer for Deno that check {deno, typescript, v8} version for users of your module and prevent them from incompatibylities error.
Use semver to check versions
Import
import ensureVersion from "https://deno.land/x/ensure_version/mod.ts";
Simply add it in your mod.ts
//some semver version constraint
ensureVersion(">1.18.0")
//or full Deno.version
ensureVersion({ deno: "1.19.2", v8: "9.9.115.7", typescript: "4.5.2" })
// Deno.version.deno = "1.9.4"
ensureVersion(">=1.8.0")
//warn minor updated
// Deno.version.deno = "1.9.4"
ensureVersion("1.9.3")
//throw version error
// Deno.version.deno = "1.9.4"
ensureVersion("1.5.2 || 1.8.0 - 2.0.0")
//pass
// Deno.version = {deno: "1.9.4", typescript: "4.5.2", v8: "9.9.115.7"}
const required = {deno: ">=1.8.0"}
ensureVersion(required, false)
//no logs
// Deno.version = {deno: "1.9.4", typescript: "4.5.2", v8: "9.9.115.7"}
const required = {deno: ">=1.8.0", typescript: "3.2.1"}
ensureVersion(required)
//throw version error
// Deno.version = {deno: "1.9.4", typescript: "4.5.2", v8: "9.9.115.7"}
const required = {}
ensureVersion(required)
//warn empty argument
// Deno.version = {deno: "1.9.4", typescript: "4.5.2", v8: "9.9.115.7"}
const required = {deno: "<1.9.5", typescript: "4.0.0 - 4.5.2", v8: "8.3.102 || 9.9.155"}
ensureVersion(required)
//pass
All the modules are exposed in mod.ts