Comparing version 0.15.1-beta to 0.15.1-beta2
var path = require("path"); | ||
var getPathTo = require(path.join(__dirname, "index")).getPathTo | ||
var getPathTo = require(path.join(__dirname, "index")).getPathTo; | ||
var spawn = require("child_process").spawn; | ||
var platform = require(path.join(__dirname, "platform")); | ||
@@ -9,4 +10,6 @@ module.exports = function(executable) { | ||
process.env.ELM_HOME = path.join(__dirname, platform.shareDir); | ||
spawn(filename, input, {stdio: 'inherit'}) | ||
.on('exit', process.exit); | ||
} | ||
}; |
@@ -7,4 +7,13 @@ var path = require("path"); | ||
}, function(exitCode) { | ||
console.error("Error - building from source failed to complete."); | ||
process.exit(exitCode); | ||
switch(typeof exitCode) { | ||
case "string": | ||
console.error(exitCode); | ||
process.exit(1); | ||
case "number": | ||
console.error("Error - building from source failed with exit code " + exitCode); | ||
process.exit(exitCode || 1); | ||
default: | ||
console.error("Error - building from source failed to complete."); | ||
process.exit(1); | ||
} | ||
}); |
@@ -11,3 +11,4 @@ var Promise = require("promise"); | ||
var mkdirp = require("mkdirp"); | ||
var distDir = path.join(__dirname, "Elm-Platform", platform.elmVersion, ".cabal-sandbox", "bin"); | ||
var distDir = platform.distDir; | ||
var shareReactorDir = platform.shareReactorDir; | ||
var expectedExecutablePaths = platform.executables.map(function(executable) { | ||
@@ -108,4 +109,63 @@ return path.join(distDir, executable); | ||
downloadBinaries().then(function(successMsg) { | ||
console.log(successMsg); | ||
function downloadReactorAssets() { | ||
var filename = "elm-reactor-assets.tar.gz"; | ||
var url = "https://dl.bintray.com/elmlang/elm-platform/" | ||
+ platform.elmVersion + "/" + filename; | ||
return new Promise(function(resolve, reject) { | ||
https.get(url, function(response) { | ||
if (response.statusCode != 200 && response.statusCode != 204) { | ||
console.log("Unable to download elm-reactor assets. elm-reactor may not work properly."); | ||
reject(response.statusCode); | ||
return; | ||
} | ||
console.log("Downloading Elm Reactor assets from " + url); | ||
var untar = tar.Extract({path: shareReactorDir, strip: 1}) | ||
.on("error", function(error) { | ||
reject("Error extracting " + filename + " - " + error); | ||
}) | ||
.on("end", function() { | ||
if (!fs.existsSync(shareReactorDir)) { | ||
reject( | ||
"Error extracting elm-reactor assets: extraction finished, but", | ||
distDir, "directory was not created.\n" + | ||
"Current directory contents: " + fs.readdirSync(__dirname) | ||
); | ||
} | ||
if (!fs.statSync(shareReactorDir).isDirectory()) { | ||
reject( | ||
"Error extracting elm-reactor assets: extraction finished, but" + | ||
distDir + "ended up being a file, not a directory. " + | ||
"This can happen when the .tar.gz file contained the " + | ||
"assets directly, instead of containing a directory with " + | ||
"the files inside."); | ||
} | ||
resolve("Successfully downloaded and processed " + filename); | ||
}); | ||
var gunzip = zlib.createGunzip() | ||
.on("error", function(error) { | ||
reject("Error decompressing " + filename + " " + error); | ||
}); | ||
response.on("error", function(error) { | ||
reject("Error receiving " + url); | ||
}).pipe(gunzip).pipe(untar); | ||
}); | ||
}); | ||
} | ||
Promise.all([ | ||
downloadBinaries(), | ||
downloadReactorAssets() | ||
]).then(function(successMessages) { | ||
successMessages.forEach(function(message) { | ||
console.log(message); | ||
}) | ||
}, function(errorMsg) { | ||
@@ -112,0 +172,0 @@ console.error(errorMsg); |
{ | ||
"name": "elm", | ||
"version": "0.15.1-beta", | ||
"version": "0.15.1-beta2", | ||
"description": "The Elm Platform: Binaries for the Elm programming language.", | ||
@@ -5,0 +5,0 @@ "preferGlobal": true, |
@@ -8,5 +8,16 @@ var Promise = require("promise"); | ||
var elmVersion = packageInfo.version.replace(/^(\d+\.\d+\.\d+).*$/, "$1"); | ||
var platformDir = path.join(__dirname, "Elm-Platform", elmVersion); | ||
var distDir = path.join(platformDir, ".cabal-sandbox", "bin"); | ||
var shareDir = path.join(platformDir, "share"); | ||
var shareReactorDir = path.join(shareDir, "reactor"); | ||
function buildFromSource() { | ||
return new Promise(function(resolve, reject) { | ||
// From the "build from source" docs: | ||
// | ||
// Now that you have chosen a home for Elm-Platform/, add the absolute path | ||
// to Elm-Platform/0.15.1/.cabal-sandbox/bin to your PATH. This is | ||
// necessary to successfully build elm-reactor which relies on elm-make. | ||
process.env.PATH = (process.env.PATH || "").split(":").concat([distDir]).join(":"); | ||
var child = spawn("runhaskell", ["BuildFromSource.hs", elmVersion], | ||
@@ -29,3 +40,6 @@ {stdio: "inherit"}); | ||
buildFromSource: buildFromSource, | ||
distDir: distDir, | ||
shareDir: shareDir, | ||
shareReactorDir: shareReactorDir, | ||
executables: Object.keys(packageInfo.bin) | ||
}; |
@@ -1,5 +0,5 @@ | ||
npm install elm | ||
npm install elm [![Build Status](https://travis-ci.org/elm-lang/elm-platform.svg?branch=master)](http://travis-ci.org/elm-lang/elm-platform) | ||
=============== | ||
Install the Elm Platform via [`npm`](https://www.npmjs.com). | ||
Install the [Elm Platform](https://github.com/elm-lang/elm-platform) via [`npm`](https://www.npmjs.com). | ||
@@ -13,1 +13,13 @@ ## Installing | ||
``` | ||
For `elm-reactor` to work properly, set your `ELM_HOME` environment variable to `/usr/local/lib/node_modules/elm/share` or the appropriate directory created on your machine. | ||
## Troubleshooting | ||
1. [Troubleshooting npm](https://github.com/npm/npm/wiki/Troubleshooting) | ||
2. On Debian/Ubuntu systems, you may have to install the nodejs-legacy package: `apt-get install nodejs-legacy`. | ||
3. If the installer says that it is building Elm from source, and that installation fails, check the [Build from Source](https://github.com/elm-lang/elm-platform/blob/master/README.md#build-from-source) documentation. | ||
## Getting Started | ||
Once everything has installed successfully, head over to the [Get Started](http://elm-lang.org/Get-Started.elm) page! |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17316
225
25
10