X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=preinstall.js;h=3fa23826d370bbdd3021e1814e2595bf4e27f319;hb=6337a3be1c44fa988f28d8f7747f1edd75dbbaf5;hp=071f1590eb2c9e922dc61abf5fd0083878e88855;hpb=03aaa7d3bbf9ff2176fe3b69138f37f5f265d186;p=github%2Ffretlink%2Fnode-dhall-json-bin.git diff --git a/preinstall.js b/preinstall.js index 071f159..3fa2382 100644 --- a/preinstall.js +++ b/preinstall.js @@ -4,6 +4,7 @@ const fs = require("fs"); const path = require("path"); const { https } = require("follow-redirects"); +const semver = require("semver"); const tar = require("tar"); const unbz2 = require("unbzip2-stream"); const unzipper = require("unzipper"); @@ -18,6 +19,9 @@ if (!dhallVersion) throw new Error("Missing DHALL_VERSION environment variable." const dhallJsonVersion = trim(pkg["dhall-json-version"] || process.env.DHALL_JSON_VERSION); if (!dhallJsonVersion) throw new Error("Missing DHALL_JSON_VERSION environment variable."); +if (semver.valid(dhallJsonVersion) && semver.lt(dhallJsonVersion, "1.2.8")) { + throw new Error(`This release of the \`${pkg.name}\` npm package installs \`json-to-dhall\`, which isn’t provided by \`dhall-json@<1.2.8\`.`); +} const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;