Skip to content

Commit

Permalink
Remove callback API from Genrator#github.username() in favor of Promi…
Browse files Browse the repository at this point in the history
…se one - ref #1006
  • Loading branch information
SBoudrias committed Mar 5, 2017
1 parent 00912ce commit 1be88e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 6 additions & 11 deletions lib/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ user.github = {};
/**
* Retrieves user's name from Git in the global scope or the project scope
* (it'll take what Git will use in the current context)
* @return {String} configured git name or undefined
*/
user.git.name = () => {
let name = nameCache.get(process.cwd());
Expand All @@ -36,6 +37,7 @@ user.git.name = () => {
/**
* Retrieves user's email from Git in the global scope or the project scope
* (it'll take what Git will use in the current context)
* @return {String} configured git email or undefined
*/
user.git.email = () => {
let email = emailCache.get(process.cwd());
Expand All @@ -54,16 +56,9 @@ user.git.email = () => {

/**
* Retrieves GitHub's username from the GitHub API
* @return {Promise} Resolved with the github username or rejected if unable to
* get the information
*/
user.github.username = cb => {
const promise = githubUsername(user.git.email());

if (cb) {
promise.then(
val => cb(null, val),
err => cb(err)
);
}

return promise;
user.github.username = () => {
return githubUsername(user.git.email());
};
5 changes: 2 additions & 3 deletions test/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ describe('Base#user', () => {
nock.restore();
});

it('is the username used by GitHub', function (done) {
this.user.github.username((_, res) => {
it('is the username used by GitHub', function () {
return this.user.github.username().then(res => {
assert.equal(res, 'mockname');
done();
});
});
});
Expand Down

0 comments on commit 1be88e6

Please sign in to comment.