Skip to content

Commit f8233cd

Browse files
committed
(fix #4819) Allow ionic login to work in a non-interactive process
1 parent 8f79cf2 commit f8233cd

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • packages/@ionic/cli/src/commands

packages/@ionic/cli/src/commands/login.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ If you are having issues logging in, please get in touch with our Support[^suppo
160160
await this.logout();
161161
await this.env.session.login(email, password);
162162
} else {
163-
if (!this.env.flags.interactive) {
163+
if (!this.env.flags.interactive && !this.env.flags.confirm) {
164164
throw new FatalException(
165165
'Refusing to attempt browser login in non-interactive mode.\n' +
166166
`If you are attempting to log in, make sure you are using a modern, interactive terminal. Otherwise, you can log in using inline username and password with ${input('ionic login <email> <password>')}. See ${input('ionic login --help')} for more details.`
@@ -170,12 +170,15 @@ If you are having issues logging in, please get in touch with our Support[^suppo
170170
this.env.log.info(`During this process, a browser window will open to authenticate you. Please leave this process running until authentication is complete.`);
171171
this.env.log.nl();
172172

173-
const login = await this.env.prompt({
174-
type: 'confirm',
175-
name: 'continue',
176-
message: 'Open the browser to log in to your Ionic account?',
177-
default: true,
178-
});
173+
let login = true;
174+
if (!this.env.flags.confirm) {
175+
login = await this.env.prompt({
176+
type: 'confirm',
177+
name: 'continue',
178+
message: 'Open the browser to log in to your Ionic account?',
179+
default: true,
180+
});
181+
}
179182

180183
if (login) {
181184
await this.logout();

0 commit comments

Comments
 (0)