exit immediately option
This commit is contained in:
parent
e29c374921
commit
7edb59324d
|
@ -493,7 +493,7 @@ export class Program {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private processResponse(response: Response) {
|
private processResponse(response: Response, exitImmediately = false) {
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (process.env.BW_QUIET !== 'true') {
|
if (process.env.BW_QUIET !== 'true') {
|
||||||
if (process.env.BW_RESPONSE === 'true') {
|
if (process.env.BW_RESPONSE === 'true') {
|
||||||
|
@ -502,7 +502,11 @@ export class Program {
|
||||||
writeLn(chalk.redBright(response.message), true);
|
writeLn(chalk.redBright(response.message), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (exitImmediately) {
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,8 +533,12 @@ export class Program {
|
||||||
writeLn(out, true);
|
writeLn(out, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (exitImmediately) {
|
||||||
|
process.exit(0);
|
||||||
|
} else {
|
||||||
process.exitCode = 0;
|
process.exitCode = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private getJson(obj: any): string {
|
private getJson(obj: any): string {
|
||||||
if (process.env.BW_PRETTY === 'true') {
|
if (process.env.BW_PRETTY === 'true') {
|
||||||
|
@ -567,7 +575,7 @@ export class Program {
|
||||||
await this.exitIfNotAuthed();
|
await this.exitIfNotAuthed();
|
||||||
const hasKey = await this.main.cryptoService.hasKey();
|
const hasKey = await this.main.cryptoService.hasKey();
|
||||||
if (!hasKey) {
|
if (!hasKey) {
|
||||||
this.processResponse(Response.error('Vault is locked.'));
|
this.processResponse(Response.error('Vault is locked.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,14 +583,14 @@ export class Program {
|
||||||
const authed = await this.main.userService.isAuthenticated();
|
const authed = await this.main.userService.isAuthenticated();
|
||||||
if (authed) {
|
if (authed) {
|
||||||
const email = await this.main.userService.getEmail();
|
const email = await this.main.userService.getEmail();
|
||||||
this.processResponse(Response.error('You are already logged in as ' + email + '.'));
|
this.processResponse(Response.error('You are already logged in as ' + email + '.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async exitIfNotAuthed() {
|
private async exitIfNotAuthed() {
|
||||||
const authed = await this.main.userService.isAuthenticated();
|
const authed = await this.main.userService.isAuthenticated();
|
||||||
if (!authed) {
|
if (!authed) {
|
||||||
this.processResponse(Response.error('You are not logged in.'));
|
this.processResponse(Response.error('You are not logged in.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue