Skip to content

Instantly share code, notes, and snippets.

@hvmonteiro
Created February 22, 2017 14:54
Show Gist options
  • Save hvmonteiro/3fb5fbf855e0c806f7de6b35d2820c0d to your computer and use it in GitHub Desktop.
Save hvmonteiro/3fb5fbf855e0c806f7de6b35d2820c0d to your computer and use it in GitHub Desktop.
Get electron-download pre-compiled binnaries for every platform to local cache directory.
const download = require('electron-download');
var downloadVersion = '1.4.15';
if (process.argv > 2) {
var downloadVersion = process.argv[2];
console.log('Using specified version', downloadVersion, '...');
} else {
console.log('Version', process.argv[2], 'using default', downloadVersion, '...');
}
/* Example
download({
version: '1.4.15',
arch: 'ia32',
platform: 'win32',
cache: './zips', // defaults to <user's home directory>/.electron
chromedriver: true,
ffmpeg: true,
mksnapshot: true,
symbols: true,
url: '', // Overwrite default download mirror
force: true // Force re-download even if it already exists locally
},function (err, zipPath) {
// zipPath will be the path of the zip that it downloaded.
// If the zip was already cached it will skip
// downloading and call the cb with the cached zip path.
// If it wasn't cached it will download the zip and save
// it in the cache path.
});
*/
// Windows
download({
version: downloadVersion ,
arch: 'ia32',
platform: 'win32',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
download({
version: downloadVersion ,
arch: 'x64',
platform: 'win32',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
// Linux
download({
version: downloadVersion ,
arch: 'ia32',
platform: 'linux',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
download({
version: downloadVersion ,
arch: 'x64',
platform: 'linux',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
download({
version: downloadVersion ,
arch: 'arm',
platform: 'linux',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
download({
version: downloadVersion ,
arch: 'armv7l',
platform: 'linux',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
// Mac OS
download({
version: downloadVersion ,
arch: 'x64',
platform: 'darwin',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
download({
version: downloadVersion ,
arch: 'x64',
platform: 'mas',
},function (err, zipPath) { if (err !== null) console.log(err);}
);
@hvmonteiro
Copy link
Author

hvmonteiro commented Feb 22, 2017

About

This will avoid electron-packager to re-download pre-compiled binaries for electron every time we are making a build.

How?

Create a file named package.js in ~/.electron and execute the following command to get the specified electron-download binary version for all platforms.

Usage:

$ node ~/.electron/package.js
or
node ~/.electron/package.js 1.4.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment