diff options
author | Cyril Sobierajewicz <cyril.sobierajewicz@fretlink.com> | 2019-08-01 17:58:29 +0200 |
---|---|---|
committer | Cyril Sobierajewicz <cyril.sobierajewicz@fretlink.com> | 2019-08-01 18:14:11 +0200 |
commit | 17386afd313f634128c79237ce1f270c72e4dc73 (patch) | |
tree | a493fb8cd9ad7ccab5a8566934b761a7d43ad176 | |
parent | 8a8fafde7315a33a81aebe01ed2bb8b5249bc62a (diff) | |
download | node-dhall-json-bin-17386afd313f634128c79237ce1f270c72e4dc73.tar.gz node-dhall-json-bin-17386afd313f634128c79237ce1f270c72e4dc73.tar.zst node-dhall-json-bin-17386afd313f634128c79237ce1f270c72e4dc73.zip |
Add `yaml-to-dhall`
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | 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 @@ | |||
15 | "bin": { | 15 | "bin": { |
16 | "dhall-to-json": "bin/dhall-to-json.exe", | 16 | "dhall-to-json": "bin/dhall-to-json.exe", |
17 | "dhall-to-yaml": "bin/dhall-to-yaml.exe", | 17 | "dhall-to-yaml": "bin/dhall-to-yaml.exe", |
18 | "json-to-dhall": "bin/json-to-dhall.exe" | 18 | "json-to-dhall": "bin/json-to-dhall.exe", |
19 | "yaml-to-dhall": "bin/yaml-to-dhall.exe" | ||
19 | }, | 20 | }, |
20 | "scripts": { | 21 | "scripts": { |
21 | "preinstall": "node ./preinstall.js" | 22 | "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 => | |||
59 | 59 | ||
60 | const dhallVersion = readVersion("dhall"); | 60 | const dhallVersion = readVersion("dhall"); |
61 | const dhallJsonVersion = readVersion("dhall-json"); | 61 | const dhallJsonVersion = readVersion("dhall-json"); |
62 | if (semver.valid(dhallJsonVersion) && semver.lt(dhallJsonVersion, "1.2.8")) { | 62 | |
63 | const isLowerThan = (version, upperBound) => | ||
64 | semver.valid(version) && semver.lt(version, upperBound); | ||
65 | |||
66 | if (isLowerThan(dhallJsonVersion, "1.2.8")) { | ||
63 | 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\`.`); | 67 | 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\`.`); |
64 | } | 68 | } |
69 | if (isLowerThan(dhallJsonVersion, "1.3.0")) { | ||
70 | 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\`.`); | ||
71 | } | ||
65 | 72 | ||
66 | const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`; | 73 | const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`; |
67 | 74 | ||