question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can arguments be passed via `electron-forge make`?

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

I see here that arguments can be passed through to electron-forge start (eg. via electron-forge start -- role=production) but can’t seem to find out how to do so through the electron-forge make command.

Would appreciate being pointed in the right direction.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (9 by maintainers)

github_iconTop GitHub Comments

7reactions
onassarcommented, Feb 27, 2018

I did that and see the limited number of options. How can I go about having arguments passed through to the package Electron app while going through the make/forge process?

2reactions
MarshallOfSoundcommented, Feb 27, 2018

@onassar That’s not possible, arguments are provided at runtime and can’t be “preconfigured”. If you want to set variables like that you should do something like so.

  • Use an environment variable (let’s set MY_APP_ROLE) and set it to the value you want
  • Use a generateAssets hook to create a file containing that information
  • Load that file in your apps logic

This would look like so

// package.json
{
  "scripts": {
    "make": "MY_APP_ROLE=prod electron-forge make"
  }
}
// forge.config.js
module.exports = {
  hooks: {
    generateAssets: async () => {
      fs.writeFileSync(
        './role.json',
        JSON.stringify({
          role: process.env.MY_APP_ROLE
        })
      );
    }
  }
}
// main.js
const { role } = require('./role.json');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can arguments be passed via electron-forge make ? #442
I see here that arguments can be passed through to electron-forge start (eg. via electron-forge start -- role=production ) but can't seem to ......
Read more >
Configuration - Electron Forge
Arguments : (packageJson: Record<string, unknown>) This hook is called every time forge attempts to read your package.json file, you will be passed in...
Read more >
How to pass command line argument in electron
In package.json its written npm start will perform electron main.js . So you will have to execute this command explicitly and pass arguments...
Read more >
A Comprehensive Guide to Building and Packaging an ...
Building and Packaging an Electron App wasn't as straight forward as I had hoped. This guide aims to help you navigate the complexities...
Read more >
electron-forge - npm
Any arguments after "start" will be passed through to your application when it's launched. Packaging your Project. electron-forge package. Yes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found