From 045515b287b7eb0142278b83939497770c2e0659 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Thu, 1 Aug 2019 18:06:12 +0200 Subject: [PATCH] Add support for macOS --- README.md | 6 ++---- package.json | 1 + preinstall.js | 8 +++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4e4fc3b..8cf297d 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,12 @@ NPM package for `dhall-json`, based on https://github.com/justinwoo/npm-psc-pack ## Installation -:warning: This package should be installed as an optional dependency until static macOS builds are available from [`dhall-haskell` releases](https://github.com/dhall-lang/dhall-haskell/releases). - There’s two installation modes: ### Locked ``` -npm install --save-optional fretlink/node-dhall-json-bin#v-- +npm install fretlink/node-dhall-json-bin#v-- ``` This will install a specific version of `dhall-json`. Replace ``, `` and `` with appropriate versions of `dhall-json`, `dhall` and this package. @@ -20,7 +18,7 @@ See [the releases](https://github.com/fretlink/node-dhall-json-bin/releases). ### Dynamic ``` -npm install --save-optional fretlink/node-dhall-json-bin +npm install fretlink/node-dhall-json-bin ``` This will install a version of `dhall-json` matching the `DHALL_JSON_VERSION` and `DHALL_VERSION` environment variables or the `dhall-json:dhall-json-version` and `dhall-json:dhall-version` [npm configuration settings](https://docs.npmjs.com/misc/config#per-package-config-settings). diff --git a/package.json b/package.json index d55964a..e01f821 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.1", "description": "NPM package for `dhall-json`, based on https://github.com/justinwoo/npm-psc-package-bin-simple.", "os": [ + "darwin", "linux", "win32" ], diff --git a/preinstall.js b/preinstall.js index d53bca2..91c3a52 100644 --- a/preinstall.js +++ b/preinstall.js @@ -85,7 +85,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 && isLowerThan(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; -- 2.41.0