]> git.immae.eu Git - github/fretlink/node-dhall-json-bin.git/blobdiff - preinstall.js
Update README.md
[github/fretlink/node-dhall-json-bin.git] / preinstall.js
index d53bca25827bca92282f3b542604d15237edfe04..8fdfbfe4c92fec147c7692ed843fefe8acce0f71 100644 (file)
@@ -60,15 +60,12 @@ 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);
 
-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\`.`);
-}
 
 const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;
 
@@ -85,7 +82,13 @@ if (process.platform === "win32") {
     res.pipe(unzipper.Extract({ path: bindir }))
   );
 } else {
-  get("x86_64-linux.tar.bz2", res =>
+  const isDarwin = process.platform === 'darwin';
+
+  if (isDarwin && isLesserThan(dhallJsonVersion, "1.4.0")) {
+    throw new Error(`Static macOS binaries aren’t provided by \`dhall-json@<1.4.0\`.`);
+  }
+
+  get(`x86_64-${isDarwin ? 'macos' : 'linux'}.tar.bz2`, res =>
     res.pipe(unbz2()).pipe(tar.x({ C: __dirname }).on("finish", () => {
       fs.readdir(bindir, (err, names) => {
         if (err) throw err;