forked from rtfeldman/node-test-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.js
41 lines (35 loc) · 1.37 KB
/
installer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module.exports = function(verbose) {
var binstall = require("binstall");
var path = require("path");
var fs = require("fs");
var packageInfo = require(path.join(__dirname, "package.json"));
// Use major.minor.patch from version string - e.g. "1.2.3" from "1.2.3-alpha"
var binVersion = packageInfo.version.match(/^(\d+\.\d+\.\d+).*$/)[1];
// 'arm', 'ia32', or 'x64'.
var arch = process.arch;
// 'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
var operatingSystem = process.platform;
var filename = operatingSystem + "-" + arch + ".tar.gz";
var url = "https://dl.bintray.com/elmlang/elm-test/" +
binVersion +
"/" +
filename;
var binariesDir = path.join(__dirname, "bin");
var packageInfo = require(path.join(__dirname, "package.json"));
var binaryExtension = process.platform === "win32" ? ".exe" : "";
var executablePaths = [
path.join(binariesDir, "elm-interface-to-json" + binaryExtension)
];
var errorMessage = "Unfortunately, there are no elm-test " +
binVersion +
" binaries available on your operating system and architecture.\n\nIf you would like to build Elm from source, there are instructions at https://github.com/elm-lang/elm-platform#build-from-source\n";
return binstall(
url,
{ path: binariesDir },
{
verbose: verbose,
verify: executablePaths,
errorMessage: errorMessage
}
);
};