0

I need to create two releases of my electron application:

  1. A silent installing exe where electron-updater is configured to automatically update in the background.
  2. An msi where the installed application does not automatically update, but just alerts the user that a new version has been released.

One way for me to do this would be to copy some sort of config into the build directory before I run electron-builder for each of the two builds, and read this config in the application to identify how to handle electron-updater events.

Before I do that I'm trying to identify whether that's the best way or not. Ideally I'd have a variable that I could send in to electron-builder that toggles the electron-updater functionality, but I don't think such a thing exists.

So the question really is:

Is it possible to use build-time variables with an electron application? If so, how?

ndtreviv
  • 3,473
  • 1
  • 31
  • 45
  • I hope you don't mind me asking, but I'm curious why you need the two different install versions? And I only ask because I wonder if there is a different solution available for what you are trying to achieve to allow the update mechanism to be simpler. On the specific question, can you check within `process.env` to see if there are any values that might help you detect the installed type? I know for Linux that if you use Snap, you can check for `process.env.SNAP` to detect if it has been installed via that method. – David Winter Oct 31 '20 at 11:21
  • 1
    @DavidWinter Corporate users prefer an MSI so they can deploy across their users machines. They don't want auto updates, either. They want total control of what goes onto user machines. The process.env stuff is interesting...I'll have to have a check...something more concrete and documented would be great, though! – ndtreviv Nov 01 '20 at 16:39

1 Answers1

0

A solution I came up with myself was to create a config.json file that I require-d into the js files I needed the data in.

Part of my build process for different package types involved overwriting the config.js file with the build-specific version in the build directory before it was all packaged.

This is not ideal, because it means that I can't build all of them with one electron-builder command, but as it happens I couldn't build the msi on my Mac anyway, so ended up issuing separate commands anyway.

ndtreviv
  • 3,473
  • 1
  • 31
  • 45