-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 8, add TypeScript definition (#9)
- Loading branch information
1 parent
d2c8fc6
commit fe861db
Showing
8 changed files
with
94 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' | ||
- '4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
Get a GitHub username from an email address. | ||
@param email - Email address for the user of whom you want the username. | ||
@param token - GitHub [personal access token](https://github.com/settings/tokens/new). | ||
@returns The username for the `email`. | ||
@example | ||
``` | ||
import githubUsername = require('github-username'); | ||
(async () => { | ||
console.log(await githubUsername('sindresorhus@gmail.com')); | ||
//=> 'sindresorhus' | ||
})(); | ||
``` | ||
*/ | ||
declare function githubUsername(email: string, token: string): Promise<string>; | ||
|
||
export = githubUsername; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {expectType} from 'tsd'; | ||
import githubUsername = require('.'); | ||
|
||
expectType<Promise<string>>( | ||
githubUsername('sindresorhus@gmail.com', 'deadbeef') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
{ | ||
"name": "github-username", | ||
"version": "4.1.0", | ||
"description": "Get a GitHub username from an email address", | ||
"license": "MIT", | ||
"repository": "sindresorhus/github-username", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"github", | ||
"user", | ||
"username", | ||
"email", | ||
"address", | ||
"gh", | ||
"git" | ||
], | ||
"dependencies": { | ||
"gh-got": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "github-username", | ||
"version": "4.1.0", | ||
"description": "Get a GitHub username from an email address", | ||
"license": "MIT", | ||
"repository": "sindresorhus/github-username", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"github", | ||
"user", | ||
"username", | ||
"email", | ||
"address", | ||
"gh", | ||
"git" | ||
], | ||
"dependencies": { | ||
"gh-got": "^8.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import test from 'ava'; | ||
import m from './'; | ||
import githubUsername from '.'; | ||
|
||
test('gets GitHub username from email', async t => { | ||
t.is(await m('sindresorhus@gmail.com'), 'sindresorhus'); | ||
t.is(await githubUsername('sindresorhus@gmail.com'), 'sindresorhus'); | ||
}); | ||
|
||
test('gets GitHub username from email using Commit Search API', async t => { | ||
t.is(await m('markdotto@gmail.com'), 'mdo'); | ||
t.is(await githubUsername('markdotto@gmail.com'), 'mdo'); | ||
}); | ||
|
||
test('rejects when GitHub has no user for the email', async t => { | ||
await t.throws(m('nogithubaccount@example.com')); | ||
await t.throwsAsync(githubUsername('nogithubaccount@example.com')); | ||
}); | ||
|
||
test('rejects when email is missing', async t => { | ||
await t.throws(m()); | ||
await t.throwsAsync(githubUsername()); | ||
}); | ||
|
||
test('rejects when email is invalid', async t => { | ||
await t.throws(m('sindresorhus_gmail.com')); | ||
await t.throwsAsync(githubUsername('sindresorhus_gmail.com')); | ||
}); | ||
|
||
test('rejects when email is not a string', async t => { | ||
await t.throws(m(() => 'sindresorhus_gmail.com')); | ||
await t.throwsAsync(githubUsername(() => 'sindresorhus_gmail.com')); | ||
}); |