如何通过 ionic 平台命令通过 Yes 来提示

Ash*_*har 2 bash shell non-interactive ionic-framework

我的 shell 脚本中有以下命令。

\n
ionic cordova platform add browser\n
Run Code Online (Sandbox Code Playgroud)\n

这提示我输入“Y”,如下所示:

\n
? Are you sure you want to continue? (Y/n)\n
Run Code Online (Sandbox Code Playgroud)\n

我希望使其成为非交互式的,因此我尝试使用Yes以下内容通过:

\n
echo Y | ionic cordova platform add browser\n\nYes | ionic cordova platform add browser\n\nionic cordova platform add browser << 'Y'\n
Run Code Online (Sandbox Code Playgroud)\n

与上述;该命令以非交互方式执行,但接受No而不是Yes如下所示:

\n
[WARN] About to add the browser platform to your app.\n\n       The browser Cordova platform is not recommended for production use.\n\n       Instead, we recommend using platform detection and browser APIs to target web/PWA. See the Cross Platform docs[1]\n       for details.\n\n       Alternatively, \xe2\x9a\xa1\xef\xb8\x8f Capacitor \xe2\x9a\xa1\xef\xb8\x8f (https://ion.link/capacitor), Ionic's official native runtime, fully supports\n       traditional web and Progressive Web Apps. See the Capacitor docs[2] to learn how easy it is to migrate.\n\n       [1]: https://ion.link/cross-platform-docs\n       [2]: https://ion.link/capacitor-cordova-migration-docs\n\n--no-confirm: Are you sure you want to continue? No\n
Run Code Online (Sandbox Code Playgroud)\n

您能否建议如何自动输入Yes并使命令非交互式?

\n

sap*_*tte 5

--confirm:打开确认提示的自动确认 --no-interactive:关闭交互式提示和花哨的输出。

应该--confirm自动接受提示

正如您在评论中指出的那样,这应该允许确认提示并具有非交互模式

ionic cordova platform add browser --confirm --no-interactive
Run Code Online (Sandbox Code Playgroud)