Skip to content

process.argv differs in built electron apps #4690

@brian-mann

Description

@brian-mann
  • Electron version: 0.36.9
  • Operating system: OSX

I have an application that can accept CLI arguments. I noticed when I built the app that process.argv is not the same as when running electron while developing.

When running electron from the command line process.argv looks like:

electron ./my-app --foo --ping=123
[
  '/Users/bmann/Dev/my-app/node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron',
  './my-app',
  '--foo',
  '--ping=123'
]

This is good because typically when you parse CLI args you do something like:
minimist(process.argv.slice(2))

This matches what its like to use node regularly such as node index.js --foo --ping=123

However when passing args directly to my built app, process.argv looks like this:

./MyApp.app/Contents/MacOS/Electron --foo --ping=123
[
  '/Users/bmann/Dev/MyApp.app/Contents/MacOS/Electron',
  '--foo',
  '--ping=123'
]

This is bad because now minimist(process.argv.slice(2)) misses the args. I get why this is happening but it is unfortunately not easy to work around, and I did not have this problem with nwjs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions