]> git.immae.eu Git - github/fretlink/node-dhall-json-bin.git/blobdiff - preinstall.js
Add `yaml-to-dhall`
[github/fretlink/node-dhall-json-bin.git] / preinstall.js
index 01db9e0f8128f76e3dfd2ea0157fb0bd7d8d16a3..d53bca25827bca92282f3b542604d15237edfe04 100644 (file)
@@ -59,9 +59,16 @@ const readVersion = name =>
 
 const dhallVersion = readVersion("dhall");
 const dhallJsonVersion = readVersion("dhall-json");
-if (semver.valid(dhallJsonVersion) && semver.lt(dhallJsonVersion, "1.2.8")) {
+
+const isLowerThan = (version, upperBound) =>
+  semver.valid(version) && semver.lt(version, upperBound);
+
+if (isLowerThan(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\`.`);
 }
+if (isLowerThan(dhallJsonVersion, "1.3.0")) {
+  throw new Error(`This release of the \`${pkg.name}\` npm package installs \`yaml-to-dhall\`, which isn’t provided by \`dhall-json@<1.3.0\`.`);
+}
 
 const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;