Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: snyk/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.233.0
Choose a base ref
...
head repository: snyk/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.234.0
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Oct 9, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    pradyunsg Pradyun Gedam
    Copy the full SHA
    6d1deba View commit details
  2. Merge pull request #810 from snyk/feat/async-await-auth

    feat: refactor auth to use async await
    lili2311 authored Oct 9, 2019
    Copy the full SHA
    27697eb View commit details
Showing with 11 additions and 17 deletions.
  1. +11 −17 src/cli/commands/auth/index.ts
28 changes: 11 additions & 17 deletions src/cli/commands/auth/index.ts
Original file line number Diff line number Diff line change
@@ -54,23 +54,17 @@ async function webAuth(via: AuthCliCommands) {

const lbl = 'Waiting...';

return (
spinner(lbl)
.then(() => {
setTimeout(() => {
open(urlStr, { wait: false });
}, 2000);
// start checking the token immediately in case they've already
// opened the url manually
return testAuthComplete(token);
})
// clear spinnger in case of success or failure
.then(spinner.clear(lbl))
.catch((error) => {
spinner.clear<void>(lbl)();
throw error;
})
);
try {
await spinner(lbl);
await setTimeout(() => {
open(urlStr, { wait: false });
}, 2000);

const res = await testAuthComplete(token);
return res;
} finally {
spinner.clear<void>(lbl)();
}
}

async function testAuthComplete(token: string): Promise<{ res; body }> {