{"action":"created","issue":{"url":"https://api.github.com/repos/electron/electron/issues/4690","repository_url":"https://api.github.com/repos/electron/electron","labels_url":"https://api.github.com/repos/electron/electron/issues/4690/labels{/name}","comments_url":"https://api.github.com/repos/electron/electron/issues/4690/comments","events_url":"https://api.github.com/repos/electron/electron/issues/4690/events","html_url":"https://github.com/electron/electron/issues/4690","id":138719776,"number":4690,"title":"process.argv differs in built electron apps","user":{"login":"brian-mann","id":1268976,"avatar_url":"https://avatars.githubusercontent.com/u/1268976?v=3","gravatar_id":"","url":"https://api.github.com/users/brian-mann","html_url":"https://github.com/brian-mann","followers_url":"https://api.github.com/users/brian-mann/followers","following_url":"https://api.github.com/users/brian-mann/following{/other_user}","gists_url":"https://api.github.com/users/brian-mann/gists{/gist_id}","starred_url":"https://api.github.com/users/brian-mann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brian-mann/subscriptions","organizations_url":"https://api.github.com/users/brian-mann/orgs","repos_url":"https://api.github.com/users/brian-mann/repos","events_url":"https://api.github.com/users/brian-mann/events{/privacy}","received_events_url":"https://api.github.com/users/brian-mann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/electron/electron/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-03-05T20:49:24Z","updated_at":"2016-05-06T13:09:08Z","closed_at":"2016-05-06T13:09:02Z","body":"* Electron version: 0.36.9\r\n* Operating system: OSX\r\n\r\nI 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.\r\n\r\nWhen running electron from the command line `process.argv` looks like:\r\n\r\n```bash\r\nelectron ./my-app --foo --ping=123\r\n```\r\n\r\n```js\r\n[\r\n  '/Users/bmann/Dev/my-app/node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron',\r\n  './my-app',\r\n  '--foo',\r\n  '--ping=123'\r\n]\r\n```\r\n\r\nThis is good because typically when you parse CLI args you do something like:\r\n`minimist(process.argv.slice(2))`\r\n\r\nThis matches what its like to use `node` regularly such as `node index.js --foo --ping=123`\r\n\r\nHowever when passing args directly to my built app, `process.argv` looks like this:\r\n\r\n```bash\r\n./MyApp.app/Contents/MacOS/Electron --foo --ping=123\r\n```\r\n\r\n```js\r\n[\r\n  '/Users/bmann/Dev/MyApp.app/Contents/MacOS/Electron',\r\n  '--foo',\r\n  '--ping=123'\r\n]\r\n```\r\n\r\nThis 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`."},"comment":{"url":"https://api.github.com/repos/electron/electron/issues/comments/217435222","html_url":"https://github.com/electron/electron/issues/4690#issuecomment-217435222","issue_url":"https://api.github.com/repos/electron/electron/issues/4690","id":217435222,"user":{"login":"zcbenz","id":639601,"avatar_url":"https://avatars.githubusercontent.com/u/639601?v=3","gravatar_id":"","url":"https://api.github.com/users/zcbenz","html_url":"https://github.com/zcbenz","followers_url":"https://api.github.com/users/zcbenz/followers","following_url":"https://api.github.com/users/zcbenz/following{/other_user}","gists_url":"https://api.github.com/users/zcbenz/gists{/gist_id}","starred_url":"https://api.github.com/users/zcbenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcbenz/subscriptions","organizations_url":"https://api.github.com/users/zcbenz/orgs","repos_url":"https://api.github.com/users/zcbenz/repos","events_url":"https://api.github.com/users/zcbenz/events{/privacy}","received_events_url":"https://api.github.com/users/zcbenz/received_events","type":"User","site_admin":true},"created_at":"2016-05-06T13:09:08Z","updated_at":"2016-05-06T13:09:08Z","body":"It is too late to change this behavior, this is going to break numerous apps. Instead I have added a `process.defaultApp` property to indicate whether the app is started by being passed as parameter to the default app, so people can use it to correctly handle this when parsing CLI parameters."}}