download.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict'
  2. const common = require('./common')
  3. const debug = require('debug')('electron-packager')
  4. const download = require('electron-download')
  5. const pify = require('pify')
  6. const semver = require('semver')
  7. const targets = require('./targets')
  8. function createDownloadOpts (opts, platform, arch) {
  9. let downloadOpts = Object.assign({}, opts.download)
  10. common.subOptionWarning(downloadOpts, 'download', 'platform', platform, opts.quiet)
  11. common.subOptionWarning(downloadOpts, 'download', 'arch', arch, opts.quiet)
  12. common.subOptionWarning(downloadOpts, 'download', 'version', opts.electronVersion, opts.quiet)
  13. return downloadOpts
  14. }
  15. module.exports = {
  16. createDownloadCombos: function createDownloadCombos (opts, selectedPlatforms, selectedArchs, ignoreFunc) {
  17. return targets.createPlatformArchPairs(opts, selectedPlatforms, selectedArchs, ignoreFunc).map(combo => {
  18. const platform = combo[0]
  19. const arch = combo[1]
  20. return createDownloadOpts(opts, platform, arch)
  21. })
  22. },
  23. createDownloadOpts: createDownloadOpts,
  24. downloadElectronZip: function downloadElectronZip (downloadOpts) {
  25. // armv7l builds have only been backfilled for Electron >= 1.0.0.
  26. // See: https://github.com/electron/electron/pull/6986
  27. /* istanbul ignore if */
  28. if (downloadOpts.arch === 'armv7l' && semver.lt(downloadOpts.version, '1.0.0')) {
  29. downloadOpts.arch = 'arm'
  30. }
  31. debug(`Downloading Electron with options ${JSON.stringify(downloadOpts)}`)
  32. return pify(download)(downloadOpts)
  33. }
  34. }