Skip to content

Commit f3d223b

Browse files
authored
Merge pull request #1754 from BrianHicks/nineteen-rc2
final working version of Elm npm installer
2 parents b26366e + 964c62f commit f3d223b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

installers/npm/bin/elm

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,34 @@
1515
// then on, it will run as normal without re-downloading.
1616

1717
var install = require("..").install;
18-
var spawn = require("child_process").spawn;
18+
var child_process = require("child_process");
1919
var path = require("path");
2020
var fs = require("fs");
2121

2222
// Make sure we get the right path even if we're executing from the symlinked
2323
// node_modules/.bin/ executable
24+
var interpreter = fs.realpathSync(process.argv[0]);
2425
var targetPath = fs.realpathSync(process.argv[1]);
2526

27+
// Figure out the binary name as we'll eventually want to execute
28+
// this. Re-executing this script doesn't always work because of varying
29+
// permissions and modes of operation across platforms (for example, Windows has
30+
// some interesting edge cases here.)
31+
var binaryName = path.join(
32+
__dirname,
33+
"..",
34+
"unpacked_bin",
35+
path.basename(targetPath)
36+
);
37+
if (process.platform === "win") {
38+
binaryName += ".exe";
39+
}
40+
2641
// cd into the directory above bin/ so install() puts bin/ in the right place.
2742
process.chdir(path.join(path.dirname(targetPath), ".."));
2843

2944
install(process.platform, process.arch).then(function() {
30-
spawn(targetPath, process.argv.slice(2), {
31-
stdio: "inherit"
32-
}).on("exit", process.exit);
33-
});
45+
child_process
46+
.spawn(binaryName, process.argv.slice(2), { stdio: "inherit" })
47+
.on("exit", process.exit);
48+
});

installers/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elm",
3-
"version": "0.19.0",
3+
"version": "0.19.0-bugfix2",
44
"description": "The Elm Platform: Binaries for the Elm programming language.",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)