From 17386afd313f634128c79237ce1f270c72e4dc73 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Thu, 1 Aug 2019 17:58:29 +0200 Subject: Add `yaml-to-dhall` --- package.json | 3 ++- preinstall.js | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 88b0204..71a1cdb 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "bin": { "dhall-to-json": "bin/dhall-to-json.exe", "dhall-to-yaml": "bin/dhall-to-yaml.exe", - "json-to-dhall": "bin/json-to-dhall.exe" + "json-to-dhall": "bin/json-to-dhall.exe", + "yaml-to-dhall": "bin/yaml-to-dhall.exe" }, "scripts": { "preinstall": "node ./preinstall.js" diff --git a/preinstall.js b/preinstall.js index 01db9e0..d53bca2 100644 --- a/preinstall.js +++ b/preinstall.js @@ -59,9 +59,16 @@ const readVersion = name => const dhallVersion = readVersion("dhall"); const dhallJsonVersion = readVersion("dhall-json"); -if (semver.valid(dhallJsonVersion) && semver.lt(dhallJsonVersion, "1.2.8")) { + +const isLowerThan = (version, upperBound) => + semver.valid(version) && semver.lt(version, upperBound); + +if (isLowerThan(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}`; -- cgit v1.2.3