2

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

ionic cordova platform add browser

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

? Are you sure you want to continue? (Y/n)

我希望使它成为非交互式的,因此我尝试Yes使用以下方法通过:

echo Y | ionic cordova platform add browser

Yes | ionic cordova platform add browser

ionic cordova platform add browser << 'Y'

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

[WARN] About to add the browser platform to your app.

       The browser Cordova platform is not recommended for production use.

       Instead, we recommend using platform detection and browser APIs to target web/PWA. See the Cross Platform docs[1]
       for details.

       Alternatively, ⚡️ Capacitor ⚡️ (https://ion.link/capacitor), Ionic's official native runtime, fully supports
       traditional web and Progressive Web Apps. See the Capacitor docs[2] to learn how easy it is to migrate.

       [1]: https://ion.link/cross-platform-docs
       [2]: https://ion.link/capacitor-cordova-migration-docs

--no-confirm: Are you sure you want to continue? No

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

4

1 回答 1

4

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

应该--confirm自动接受提示

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

ionic cordova platform add browser --confirm --no-interactive
于 2020-07-24T12:20:55.783 回答