Skip to content

Commit

Permalink
Fix getAPICredentials so it looks in local RC first then global RC (#168
Browse files Browse the repository at this point in the history
)

Signed-off-by: campionfellin <campionfellin@gmail.com>
  • Loading branch information
campionfellin authored and grant committed May 15, 2018
1 parent 85bdebd commit 731e734
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ commander
console.log(e);
});
});
}, true);
});
});

/**
Expand Down
16 changes: 10 additions & 6 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ export const oauth2Client = new OAuth2Client({
* @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, isLocal?: boolean) {
const dotfile = isLocal ? DOTFILE.RC_LOCAL : DOTFILE.RC;
dotfile.read().then((rc: ClaspSettings) => {
export function getAPICredentials(cb: (rc: ClaspSettings | void) => void) {
DOTFILE.RC_LOCAL.read().then((rc: ClaspSettings) => {
oauth2Client.setCredentials(rc);
cb(rc);
}).catch((err: object) => {
console.error('Could not read API credentials. Error:');
console.error(err);
process.exit(-1);
DOTFILE.RC.read().then((rc: ClaspSettings) => {
oauth2Client.setCredentials(rc);
cb(rc);
}).catch((err: object) => {
console.error('Could not read API credentials. Error:');
console.error(err);
process.exit(-1);
});
});
}

Expand Down

0 comments on commit 731e734

Please sign in to comment.