From: Cyril Sobierajewicz Date: Fri, 17 May 2019 22:17:02 +0000 (+0200) Subject: Add `json-to-dhall` X-Git-Tag: v1.2.8-1.22.0-1.0.0~6 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=6337a3be1c44fa988f28d8f7747f1edd75dbbaf5;p=github%2Ffretlink%2Fnode-dhall-json-bin.git Add `json-to-dhall` --- diff --git a/package-lock.json b/package-lock.json index 2637fdc..2617e32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -267,6 +267,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "semver": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", + "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==" + }, "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", diff --git a/package.json b/package.json index f81e02c..7d55765 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ ], "bin": { "dhall-to-json": "bin/dhall-to-json.exe", - "dhall-to-yaml": "bin/dhall-to-yaml.exe" + "dhall-to-yaml": "bin/dhall-to-yaml.exe", + "json-to-dhall": "bin/json-to-dhall.exe" }, "scripts": { "preinstall": "node ./preinstall.js" @@ -30,6 +31,7 @@ "homepage": "https://github.com/cyrilfretlink/node-dhall-json#readme", "dependencies": { "follow-redirects": "^1.7.0", + "semver": "^6.0.0", "tar": "^4.4.8", "unbzip2-stream": "^1.3.3", "unzipper": "^0.9.12" diff --git a/preinstall.js b/preinstall.js index 071f159..3fa2382 100644 --- a/preinstall.js +++ b/preinstall.js @@ -4,6 +4,7 @@ const fs = require("fs"); const path = require("path"); const { https } = require("follow-redirects"); +const semver = require("semver"); const tar = require("tar"); const unbz2 = require("unbzip2-stream"); const unzipper = require("unzipper"); @@ -18,6 +19,9 @@ if (!dhallVersion) throw new Error("Missing DHALL_VERSION environment variable." const dhallJsonVersion = trim(pkg["dhall-json-version"] || process.env.DHALL_JSON_VERSION); if (!dhallJsonVersion) throw new Error("Missing DHALL_JSON_VERSION environment variable."); +if (semver.valid(dhallJsonVersion) && semver.lt(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\`.`); +} const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;