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` --- preinstall.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to '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