aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2020-05-12 10:59:05 +0200
committerCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2020-05-12 11:19:13 +0200
commit41d2f5f572fbc8ce27048843f9c5c6b70a45450b (patch)
tree1cf79aa074061a100f2c10870fdb2e72f4035f03
parent3ad6fbb588c5a21ad3cc00322b2fc43c8ff81403 (diff)
downloadnode-dhall-json-bin-41d2f5f572fbc8ce27048843f9c5c6b70a45450b.tar.gz
node-dhall-json-bin-41d2f5f572fbc8ce27048843f9c5c6b70a45450b.tar.zst
node-dhall-json-bin-41d2f5f572fbc8ce27048843f9c5c6b70a45450b.zip
Add an upper bound to the `dhall-json` versions providing `yaml-to-dhall`
-rw-r--r--preinstall.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/preinstall.js b/preinstall.js
index 91c3a52..292b73b 100644
--- a/preinstall.js
+++ b/preinstall.js
@@ -60,14 +60,16 @@ const readVersion = name =>
60const dhallVersion = readVersion("dhall"); 60const dhallVersion = readVersion("dhall");
61const dhallJsonVersion = readVersion("dhall-json"); 61const dhallJsonVersion = readVersion("dhall-json");
62 62
63const isLowerThan = (version, upperBound) => 63const isLesserThan = (version, upperBound) =>
64 semver.valid(version) && semver.lt(version, upperBound); 64 semver.valid(version) && semver.lt(version, upperBound);
65const isGreaterThan = (version, lowerBound) =>
66 semver.valid(version) && semver.gt(version, lowerBound);
65 67
66if (isLowerThan(dhallJsonVersion, "1.2.8")) { 68if (isLesserThan(dhallJsonVersion, "1.2.8")) {
67 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\`.`); 69 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\`.`);
68} 70}
69if (isLowerThan(dhallJsonVersion, "1.3.0")) { 71if (isLesserThan(dhallJsonVersion, "1.3.0") || isGreaterThan(dhallJsonVersion, "1.5.0")) {
70 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\`.`); 72 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\`.`);
71} 73}
72 74
73const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`; 75const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;
@@ -87,7 +89,7 @@ if (process.platform === "win32") {
87} else { 89} else {
88 const isDarwin = process.platform === 'darwin'; 90 const isDarwin = process.platform === 'darwin';
89 91
90 if (isDarwin && isLowerThan(dhallJsonVersion, "1.4.0")) { 92 if (isDarwin && isLesserThan(dhallJsonVersion, "1.4.0")) {
91 throw new Error(`Static macOS binaries aren’t provided by \`dhall-json@<1.4.0\`.`); 93 throw new Error(`Static macOS binaries aren’t provided by \`dhall-json@<1.4.0\`.`);
92 } 94 }
93 95