-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.js
32 lines (26 loc) · 1.15 KB
/
install.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
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.replace(/^(\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-platform/"
+ binVersion + "/" + filename;
var binariesDir = path.join(__dirname, "binaries");
var packageInfo = require(path.join(__dirname, "package.json"));
var binaryExtension = process.platform === "win32" ? ".exe" : "";
var executablePaths = Object.keys(packageInfo.bin).map(function(executable) {
return path.join(binariesDir, executable + binaryExtension);
});
binstall(url, {path: binariesDir, strip: 1}, {verbose: true, verify: executablePaths})
.then(function(successMessage) {
console.log(successMessage);
}, function(errorMessage) {
console.error(errorMessage);
process.exit(1);
});