]> git.immae.eu Git - github/fretlink/node-dhall-json-bin.git/blobdiff - preinstall.js
Merge pull request #3 from cyrilfretlink/yaml-to-dhall-upper-bound
[github/fretlink/node-dhall-json-bin.git] / preinstall.js
index 91c3a523f0ac26616a2d79147d88621e1f78774c..292b73b961ff8d518baac93cfd48de5f6e11e2c9 100644 (file)
@@ -60,14 +60,16 @@ const readVersion = name =>
 const dhallVersion = readVersion("dhall");
 const dhallJsonVersion = readVersion("dhall-json");
 
-const isLowerThan = (version, upperBound) =>
+const isLesserThan = (version, upperBound) =>
   semver.valid(version) && semver.lt(version, upperBound);
+const isGreaterThan = (version, lowerBound) =>
+  semver.valid(version) && semver.gt(version, lowerBound);
 
-if (isLowerThan(dhallJsonVersion, "1.2.8")) {
+if (isLesserThan(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\`.`);
+if (isLesserThan(dhallJsonVersion, "1.3.0") || isGreaterThan(dhallJsonVersion, "1.5.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 >1.5.0\`.`);
 }
 
 const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;
@@ -87,7 +89,7 @@ if (process.platform === "win32") {
 } else {
   const isDarwin = process.platform === 'darwin';
 
-  if (isDarwin && isLowerThan(dhallJsonVersion, "1.4.0")) {
+  if (isDarwin && isLesserThan(dhallJsonVersion, "1.4.0")) {
     throw new Error(`Static macOS binaries aren’t provided by \`dhall-json@<1.4.0\`.`);
   }