Skip to content

Commit

Permalink
Merge branch 'master' of github.com:google/clasp into generate-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
grant committed Jun 1, 2018
2 parents 30898fe + 2d8ba8e commit 060d813
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 300 deletions.
22 changes: 9 additions & 13 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,19 @@ async function authorize(useLocalhost: boolean, writeToOwnKey: boolean) {
/**
* Loads the Apps Script API credentials for the CLI.
* Required before every API call.
* @param {Function} cb The callback
* @param {boolean} isLocal If we should load local API credentials for this clasp project.
*/
export function getAPICredentials(cb: (rc: ClaspSettings | void) => void) {
DOTFILE.RC_LOCAL.read().then((rc: ClaspSettings) => {
export async function loadAPICredentials() {
return DOTFILE.RC_LOCAL.read().then((rc: ClaspSettings) => {
oauth2Client.setCredentials(rc);
}).catch((err: any) => {
return DOTFILE.RC.read().then((rc: ClaspSettings) => {
oauth2Client.setCredentials(rc);
cb(rc);
}).catch((err: any) => {
DOTFILE.RC.read().then((rc: ClaspSettings) => {
oauth2Client.setCredentials(rc);
cb(rc);
}).catch((err: any) => {
console.error('Could not read API credentials. Error:');
console.error(err);
process.exit(-1);
});
console.error('Could not read API credentials. Error:');
console.error(err);
process.exit(1);
});
});
}

/**
Expand Down
Loading

0 comments on commit 060d813

Please sign in to comment.