@@ -1,5 +1,6 @@
1var fs = require('fs');
1var fs = require('fs');
2var package = require('./package.json');
2var package = require('./package.json');
3+var path = require('path');
3var request = require('request');
4var request = require('request');
4var zlib = require('zlib');
5var zlib = require('zlib');
@@ -11,7 +12,7 @@ var zlib = require('zlib');
11// called when --ignore-scripts is enabled. That's why install.js is so weird.
12// called when --ignore-scripts is enabled. That's why install.js is so weird.
14−module.exports = function(destinationPath, callback)
15+module.exports = function(callback)
16 // figure out URL of binary
17 // figure out URL of binary
17 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
18 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
@@ -19,6 +20,9 @@ module.exports = function(destinationPath, callback)
19 var arch = { 'x64': '64-bit', 'ia32': '32-bit' }[process.arch];
20 var arch = { 'x64': '64-bit', 'ia32': '32-bit' }[process.arch];
20 var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
21 var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
23+ // figure out where to put the binary (calls path.resolve() to get path separators right on Windows)
24+ var binaryPath = path.resolve(__dirname, package.bin) + (process.platform === 'win32' ? '.exe' : '');
22 // set up handler for request failure
26 // set up handler for request failure
23 function reportDownloadFailure(error)
27 function reportDownloadFailure(error)
@@ -31,7 +35,7 @@ module.exports = function(destinationPath, callback)
33 // set up file write pipe
37 // set up file write pipe
34− var write = fs.createWriteStream(destinationPath, {
38+ var write = fs.createWriteStream(binaryPath, {
35 encoding: 'binary',
39 encoding: 'binary',
36 mode: 0o755
40 mode: 0o755
37 }).on('finish', callback).on('error', function(error) {
41 }).on('finish', callback).on('error', function(error) {