Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in storeToken() #2

Open
sjbyrnes opened this issue Aug 21, 2018 · 1 comment
Open

bug in storeToken() #2

sjbyrnes opened this issue Aug 21, 2018 · 1 comment

Comments

@sjbyrnes
Copy link

sjbyrnes commented Aug 21, 2018

in auth.js:

If the TOKEN_DIR exists, the error will always be thrown and the token will never be stored.

function storeToken(token) {
  try {
    fs.mkdirSync(TOKEN_DIR);
    fs.writeFileSync(TOKEN_PATH, JSON.stringify(token));
  } catch (err) {
    if (err.code != 'EEXIST') return err;
  }
  console.log('Token stored to ' + TOKEN_PATH);
}

Should be:

function storeToken(token) {
    try {
        fs.mkdirSync(TOKEN_DIR);
    } catch (err) {
        if (err.code != 'EEXIST') return err;
    }
    try {
        fs.writeFileSync(TOKEN_PATH, JSON.stringify(token));
    } catch (err) {
        return err;
    }
    console.log('Token stored to ' + TOKEN_PATH);
}
@grant
Copy link
Contributor

grant commented Aug 7, 2019

PRs welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants