将命令行参数传递给电子可执行文件(安装已打包的应用程序后) [英] Passing command line arguments to electron executable (after installing an already packaged app)
问题描述
我正在尝试在执行时将命令行参数传递给我已经打包的应用程序.(已经与electronic-builder打包并在Mac上安装了.dmg)
I'm trying to pass command line arguments to my already packaged app on execution. (Already packaged with electron-builder and installed the .dmg on my mac)
我导航到应用程序可执行文件所在的/Applications/myApp.app/Contents/MacOS
文件夹.然后我跑. exec myApp --myNewArgumenttheFancyValue
由于某些原因,"myNewArgument"没有出现在我的process.argv数组中.
I navigated into the /Applications/myApp.app/Contents/MacOS
folder where the application executable is located. Then i run.
exec myApp --myNewArgument theFancyValue
For some reason "myNewArgument" does not appear in my process.argv array.
我想念什么吗?我认为这些争论将自动传递给我的电子主流程.
Am i missing anything? I thought the arguements will automaticly be passed to my electron main process.
非常感谢您的帮助.
推荐答案
是的,传递的命令行参数出现在 process.argv
数组中,但仅在主进程中出现.
Yes, the passed command line arguments appear in the process.argv
array, but only from the main process.
在渲染器进程中,您需要使用 查看全文