Skip to content

Commit

Permalink
exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Goh committed Nov 3, 2015
1 parent 2b699b9 commit e6c92e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 4 additions & 1 deletion cli/script/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ function run(): void {
}

execute(parser.command)
.catch((error: any): void => console.error(chalk.red("[Error] " + error.message)))
.catch((error: any): void => {
console.error(chalk.red("[Error] " + error.message))
process.exit(1);
})
.done();
}

Expand Down
14 changes: 4 additions & 10 deletions cli/script/command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ function accessKeyList(command: cli.IAccessKeyListCommand): Promise<void> {
}

function removeLocalAccessKey(): Promise<void> {
return Promise<void>((resolve, reject, notify): void => {
log(chalk.red("[Error] Cannot remove the access key for the current session. Please run 'code-push logout' if you would like to remove this access key."));
});
return Q.fcall(() => { throw new Error("Cannot remove the access key for the current session. Please run 'code-push logout' if you would like to remove this access key."); });
}

function accessKeyRemove(command: cli.IAccessKeyRemoveCommand): Promise<void> {
Expand Down Expand Up @@ -299,9 +297,7 @@ function deserializeConnectionInfo(): IStandardLoginConnectionInfo|IAccessKeyLog
}

function notifyAlreadyLoggedIn(): Promise<void> {
return Promise<void>((resolve, reject, notify): void => {
log("You are already logged in from this machine.");
});
return Q.fcall(() => { throw new Error("You are already logged in from this machine."); });
}

export function execute(command: cli.ICommand): Promise<void> {
Expand Down Expand Up @@ -494,9 +490,7 @@ function loginWithAccessTokenInternal(serverUrl: string): Promise<void> {
}

if (!accessToken) {
log("Invalid access token.");

return;
throw new Error("Invalid access token.");
}

sdk = new AccountManager(serverUrl);
Expand Down Expand Up @@ -531,7 +525,7 @@ function logout(): Promise<void> {
});
}

return Q(<void>null);
return Q.fcall(() => { throw new Error("You are already logged in from this machine."); });
}

function printDeploymentList(command: cli.IDeploymentListCommand, deployments: Deployment[], deploymentKeys: Array<string>): void {
Expand Down

0 comments on commit e6c92e9

Please sign in to comment.