]>
git.immae.eu Git - github/fretlink/node-dhall-json-bin.git/blob - preinstall.js
1b859fc42ec98503bbb03a94e0983105c3355cb8
3 const { https
} = require("follow-redirects");
4 const tar
= require("tar");
5 const unbz2
= require("unbzip2-stream");
7 const pkg
= require("./package.json");
9 const trim
= str
=> str
&& String(str
).trim();
11 const dhallVersion
= trim(pkg
["dhall-version"] || process
.env
.DHALL_VERSION
);
12 if (!dhallVersion
) throw new Error("Missing DHALL_VERSION environment variable.");
14 const dhallJsonVersion
= trim(pkg
["dhall-json-version"] || process
.env
.DHALL_JSON_VERSION
);
15 if (!dhallJsonVersion
) throw new Error("Missing DHALL_JSON_VERSION environment variable.");
17 const release
= `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`;
19 const url
= `${release}-x86_64-linux.tar.bz2`;
20 https
.get(url
, res
=> {
21 if (res
.statusCode
>= 400) throw new Error(`Error fetching ${url}: ${res.statusMessage}`);
22 res
.pipe(unbz2()).pipe(tar
.x({ C: __dirname
}));