如何通过离子平台命令提示 Yes

How to pass Yes to prompt by ionic platform command

我的 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 并使命令成为非交互式的?

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

--confirm 应该自动接受提示

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

ionic cordova platform add browser --confirm --no-interactive