minimistjs / minimist

parse argument options
MIT License
515 stars 30 forks source link

Hint to Electron developers? #43

Open datenreisender opened 1 year ago

datenreisender commented 1 year ago

README.md contains the example require('minimist')(process.argv.slice(2));.

That, of course, is correct for the many people developing plain node applications.

But on Electron (which is a big platform) developers need to be a bit careful because there it depends on how the app is ran to determine how many arguments to slice off. There (but only there!) something likerequire('minimist')(process.argv.slice(process.defaultApp ? 2 : 1)); would be wise to use.

Should this be mentioned?

ljharb commented 1 year ago

That seems like one of those universal things that an electron developer has to know - and usually those aren’t documented anywhere but with electron (in this example)

datenreisender commented 1 year ago

Ah, one more detail: I switched from yargs to minimist because I didn't need all the bells and whistles of the former. yargs does have this functionality out of the box. This is one of the reasons it lead me to this pitfall (another being that this likely does not happen during the initial development).

I think it is correct that minimist does not do this automatically like yargs, as this really is a special case. I just thought it might be common enough, that you might would like to mention it.

ljharb commented 1 year ago

It can't hurt, I suppose - although electron is a pretty uncommon use case overall, I'd expect (it gets 600K downloads a week, this package gets 50M, to put it in perspective).