Skip to content
Permalink
Browse files

fix(publisher): throw an exception if a GitHub token isn't specified

  • Loading branch information
malept committed Feb 6, 2017
1 parent b93b6cf commit bc299b7a8dccf7d07e27457f1e6c4819c6207deb
Showing with 11 additions and 2 deletions.
  1. +1 −1 src/publishers/github.js
  2. +3 −1 src/util/github.js
  3. +7 −0 test/fast/github_spec.js
@@ -9,7 +9,7 @@ export default async (artifacts, packageJSON, forgeConfig, authToken, tag) => {
throw 'In order to publish to github you must set the "github_repository.owner" and "github_repository.name" properties in your forge config. See the docs for more info'; // eslint-disable-line
}

const github = new GitHub(authToken);
const github = new GitHub(authToken, true);

let release;
await asyncOra('Searching for target Release', async () => {
@@ -1,11 +1,13 @@
import GitHubAPI from 'github';

export default class GitHub {
constructor(authToken) {
constructor(authToken, requireAuth) {
if (authToken) {
this.token = authToken;
} else if (process.env.GITHUB_TOKEN) {
this.token = process.env.GITHUB_TOKEN;
} else if (requireAuth) {
throw 'Please set GITHUB_TOKEN in your environment to access these features';
}
}

@@ -56,5 +56,12 @@ describe('GitHub', () => {
gh.getGitHub();
expect(gitHubAuthSpy.callCount).to.equal(0);
});

it('should throw an exception if a token is required', () => {
expect(() => {
const gh = new GitHub(null, true);
gh.getGitHub();
}).to.throw('Please set GITHUB_TOKEN in your environment to access these features');
});
});
});

0 comments on commit bc299b7

Please sign in to comment.
You can’t perform that action at this time.