on master help sign in
add check if desired file already exists, skip download if so
33e43e8Evan Czaplicki
installers/npm/bin/elm+2−1
@@ -11,7 +11,8 @@ var fs = require('fs');
11//
11//
12// This file pretends to be the downloaded binary. It then downloads
12// This file pretends to be the downloaded binary. It then downloads
13// the real binary over itself. So in that case, the first run would
13// the real binary over itself. So in that case, the first run would
14−// also make an HTTPS request to fetch the real binary.
14+// also make an HTTPS request to fetch the real binary. From there,
15+// it calls the binary it downloaded on each run.
15
16
16
17
17
18
installers/npm/download.js+6−5
@@ -17,12 +17,13 @@ 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
22
21− download(
23+ // check if exists for bin/elm running for the Nth time on Windows
22− process.platform === 'win32' ? destinationPath + '.exe' : destinationPath,
24+ fs.existsSync(path)
23− 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz',
25+ ? callback()
24− callback
26+ : download(path, url, callback);
25− );
26};
27};
27
28
28
29