bashshellionic-frameworknon-interactive

How to pass Yes to prompt by ionic platform command


I have the below command in my shell script.

ionic cordova platform add browser

which prompts me to input 'Y' as below:

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

I wish to make this non-interactive thus i try to pass Yes using the below:

echo Y | ionic cordova platform add browser

Yes | ionic cordova platform add browser

ionic cordova platform add browser << 'Y'

With the above; the command executes non-interactive but accepts No instead of Yes as can be seen below:

[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

Can you please suggest how to auto-enter Yes and make the command non-interactive ?


Solution

  • --confirm: Turn on auto-confirmation of confirmation prompts --no-interactive: Turn off interactive prompts and fancy outputs.

    The --confirm should auto-accept the prompt

    As you pointed out in your comment, this should allow to confirm the prompt and have a non-interactive mode

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