on master help sign in
try out elm.cmd trick to see if it works on mac and windows
127a28eEvan Czaplicki
installers/npm/bin/elm → installers/npm/bin/elm.cmdrenamed+3−3
@@ -18,12 +18,12 @@ var fs = require('fs');
18
18
19// Make sure we get the right path even if we're executing from the symlinked
19// Make sure we get the right path even if we're executing from the symlinked
20// node_modules/.bin/ executable
20// node_modules/.bin/ executable
21−var pathToThisFile = fs.realpathSync(process.argv[1]);
21+var targetPath = fs.realpathSync(process.argv[1]);
22
22
23−download(pathToThisFile, function() {
23+download(targetPath, function() {
24 // Need double quotes and { shell: true } when there are spaces in the path on windows:
24 // Need double quotes and { shell: true } when there are spaces in the path on windows:
25 // https://github.com/nodejs/node/issues/7367#issuecomment-229721296
25 // https://github.com/nodejs/node/issues/7367#issuecomment-229721296
26 child_process
26 child_process
27− .spawn('"' + pathToThisFile + '"', process.argv.slice(2), { stdio: 'inherit', shell: true })
27+ .spawn('"' + targetPath + '"', process.argv.slice(2), { stdio: 'inherit', shell: true })
28 .on('exit', process.exit);
28 .on('exit', process.exit);
29});
29});
installers/npm/download.js+1−6
@@ -17,13 +17,8 @@ module.exports = function(destinationPath, callback)
17 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
17 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
18 var os = { 'darwin': 'mac', 'win32': 'windows', 'linux': 'linux' }[process.platform];
18 var os = { 'darwin': 'mac', 'win32': 'windows', 'linux': 'linux' }[process.platform];
19 var arch = { 'x64': '64-bit', 'ia32': '32-bit' }[process.arch];
19 var arch = { 'x64': '64-bit', 'ia32': '32-bit' }[process.arch];
20− var path = process.platform === 'win32' ? destinationPath + '.exe' : destinationPath;
21 var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
20 var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
22−
23− // check if exists for bin/elm running for the Nth time on Windows
24− fs.existsSync(path)
25− ? callback()
26− : download(path, url, callback);
21+ download(destinationPath, url, callback);
27};
22};
28
23
29
24
installers/npm/install.js+1−1
@@ -5,6 +5,6 @@ var path = require('path');
5
5
6
6
7// get slashes right for Windows
7// get slashes right for Windows
8−var targetPath = path.resolve(__dirname, Object.values(package.bin)[0]);
8+var targetPath = path.resolve(__dirname, package.bin['elm']);
9
9
10download(targetPath, function() {});
10download(targetPath, function() {});
installers/npm/package.json+2−2
@@ -25,7 +25,7 @@
25 "install.js",
25 "install.js",
26 "download.js",
26 "download.js",
27 "bin",
27 "bin",
28− "bin/elm"
28+ "bin/elm.cmd"
29 ],
29 ],
30 "keywords": [
30 "keywords": [
31 "bin",
31 "bin",
@@ -36,7 +36,7 @@
36 "installer"
36 "installer"
37 ],
37 ],
38 "bin": {
38 "bin": {
39− "elm": "bin/elm"
39+ "elm": "bin/elm.cmd"
40 },
40 },
41 "dependencies": {
41 "dependencies": {
42 }
42 }