From 731e734311f9dae7a8cc9d676f0433f4eb6d3231 Mon Sep 17 00:00:00 2001 From: Campion Fellin Date: Tue, 15 May 2018 10:23:39 -0700 Subject: [PATCH] Fix getAPICredentials so it looks in local RC first then global RC (#168) Signed-off-by: campionfellin --- index.ts | 2 +- src/auth.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index bbb249e7..d6dff87f 100755 --- a/index.ts +++ b/index.ts @@ -828,7 +828,7 @@ commander console.log(e); }); }); - }, true); + }); }); /** diff --git a/src/auth.ts b/src/auth.ts index 5306182f..ca2a337a 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -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); + }); }); }