Skip to content

Commit 92455bb

Browse files
committed
Resolve merge conflicts.
2 parents 4d3f075 + edf3270 commit 92455bb

File tree

12 files changed

+174
-30
lines changed

12 files changed

+174
-30
lines changed

.travis.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- '6'
5-
- '5'
6-
- '4'
7-
4+
- '11'
5+
- '10'
6+
- '8'
87
cache:
98
directories:
10-
- node_modules
9+
- node_modules
1110
before_install: npm install -g npm@latest
1211
before_script:
13-
- npm run lint
14-
# - npm run build # will need this when we do sauce testing of compiled files
12+
- npm run lint
1513
script:
16-
- npm run test-coverage
17-
# - npm run test-dist # test the compiled files
14+
- npm run test-coverage
1815
after_success:
19-
- npm run codecov
16+
- npm run codecov
2017
before_deploy:
21-
- npm run build
18+
- npm run build
2219
deploy:
2320
provider: npm
2421
skip_cleanup: true
2522
on:
2623
tags: true
2724
email: clayreimann@gmail.com
2825
api_key:
29-
secure: TZHqJ9Kh2Qf0GAVDjEOQ01Ez6rGMYHKwVLOKTbnb7nSzF7iiGNT4UwzvYawm0T9p1k7X1WOqW3l7OEbIwoKl7/9azT4BBJm7qUMRfB9Zio5cL3rKubJVz7+LEEIW4iBeDWLanhUDgy9BO2JKCt8bfp/U2tltgXtu9Fm/UFPALI8=
26+
secure: WnLh1m02aF7NvFNILCZ8KsjPuDeSddQI87y8dwAixStr2FhQyz8FIKZN2Qj1N1Q9ZJvBETe5HWs1c9yOjTKBkD0d/eU2hlpnB9WXEFRJVDjiUuMnpAMMvuqTZwYg6kXq5N+of95PX58AYiBiV/qwsdUr/MgjEEYLt5UZgRYQRvE=

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Travis](https://img.shields.io/travis/github-tools/github.svg?maxAge=60)][travis-ci]
1010
[![Codecov](https://img.shields.io/codecov/c/github/github-tools/github.svg?maxAge=2592000)][codecov]
1111

12-
Github.js provides a minimal higher-level wrapper around Github's API.
12+
`Github.js` provides a minimal higher-level wrapper around Github's API.
1313

1414
## Usage
1515

@@ -71,7 +71,7 @@ clayreimann.listStarredRepos(function(err, repos) {
7171
should include updated JSDoc.
7272

7373
## Installation
74-
Github.js is available from `npm` or [unpkg][unpkg].
74+
`Github.js` is available from `npm` or [unpkg][unpkg].
7575

7676
```shell
7777
npm install github-api
@@ -86,10 +86,7 @@ npm install github-api
8686
```
8787

8888
## Compatibility
89-
`Github.js` is tested on Node.js:
90-
* 6.x
91-
92-
Note: `Github.js` uses Promise, hence it will not work in Node.js < 4 without polyfill.
89+
`Github.js` is tested on node's LTS and current versions.
9390

9491
[codecov]: https://codecov.io/github/github-tools/github?branch=master
9592
[docs]: http://github-tools.github.io/github/

lib/GitHub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GitHub {
3434

3535
/**
3636
* Create a new Gist wrapper
37-
* @param {number} [id] - the id for the gist, leave undefined when creating a new gist
37+
* @param {string} [id] - the id for the gist, leave undefined when creating a new gist
3838
* @return {Gist}
3939
*/
4040
getGist(id) {

lib/Markdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Markdown extends Requestable {
3232
* @return {Promise} - the promise for the http request
3333
*/
3434
render(options, cb) {
35-
return this._request('POST', '/markdown', options, cb);
35+
return this._request('POST', '/markdown', options, cb, true);
3636
}
3737
}
3838

lib/Repository.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import debug from 'debug';
1414
const log = debug('github:repository');
1515

1616
/**
17-
* Respository encapsulates the functionality to create, query, and modify files.
17+
* Repository encapsulates the functionality to create, query, and modify files.
1818
*/
1919
class Repository extends Requestable {
2020
/**
@@ -188,7 +188,10 @@ class Repository extends Requestable {
188188
*/
189189
listCommits(options, cb) {
190190
options = options || {};
191-
191+
if (typeof options === 'function') {
192+
cb = options;
193+
options = {};
194+
}
192195
options.since = this._dateToISO(options.since);
193196
options.until = this._dateToISO(options.until);
194197

@@ -334,16 +337,26 @@ class Repository extends Requestable {
334337
* @param {string} parent - the SHA of the parent commit
335338
* @param {string} tree - the SHA of the tree for this commit
336339
* @param {string} message - the commit message
340+
* @param {Object} [options] - commit options
341+
* @param {Object} [options.author] - the author of the commit
342+
* @param {Object} [options.commiter] - the committer
337343
* @param {Requestable.callback} cb - will receive the commit that is created
338344
* @return {Promise} - the promise for the http request
339345
*/
340-
commit(parent, tree, message, cb) {
346+
commit(parent, tree, message, options, cb) {
347+
if (typeof options === 'function') {
348+
cb = options;
349+
options = {};
350+
}
351+
341352
let data = {
342353
message,
343354
tree,
344355
parents: [parent],
345356
};
346357

358+
data = Object.assign({}, options, data);
359+
347360
return this._request('POST', `/repos/${this.__fullname}/git/commits`, data, cb)
348361
.then((response) => {
349362
this.__currentTree.sha = response.data.sha; // Update latest commit
@@ -494,6 +507,18 @@ class Repository extends Requestable {
494507
return this._request('POST', `/repos/${this.__fullname}/forks`, null, cb);
495508
}
496509

510+
/**
511+
* Fork a repository to an organization
512+
* @see https://developer.github.com/v3/repos/forks/#create-a-fork
513+
* @param {String} org - organization where you'd like to create the fork.
514+
* @param {Requestable.callback} cb - will receive the information about the newly created fork
515+
* @return {Promise} - the promise for the http request
516+
*
517+
*/
518+
forkToOrg(org, cb) {
519+
return this._request('POST', `/repos/${this.__fullname}/forks?organization=${org}`, null, cb);
520+
}
521+
497522
/**
498523
* List a repository's forks
499524
* @see https://developer.github.com/v3/repos/forks/#list-forks

lib/Requestable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Requestable {
124124

125125
/**
126126
* if a `Date` is passed to this function it will be converted to an ISO string
127-
* @param {*} date - the object to attempt to cooerce into an ISO date string
127+
* @param {*} date - the object to attempt to coerce into an ISO date string
128128
* @return {string} - the ISO representation of `date` or whatever was passed in if it was not a date
129129
*/
130130
_dateToISO(date) {
@@ -235,7 +235,7 @@ class Requestable {
235235
* @param {string} path - the path to request
236236
* @param {Object} options - the query parameters to include
237237
* @param {Requestable.callback} [cb] - the function to receive the data. The returned data will always be an array.
238-
* @param {Object[]} results - the partial results. This argument is intended for interal use only.
238+
* @param {Object[]} results - the partial results. This argument is intended for internal use only.
239239
* @return {Promise} - a promise which will resolve when all pages have been fetched
240240
* @deprecated This will be folded into {@link Requestable#_request} in the 2.0 release.
241241
*/

lib/User.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ class User extends Requestable {
8181
return this._request('GET', this.__getScopedUrl('orgs'), null, cb);
8282
}
8383

84+
/**
85+
* List followers of a user
86+
* @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user
87+
* @param {Requestable.callback} [cb] - will receive the list of followers
88+
* @return {Promise} - the promise for the http request
89+
*/
90+
listFollowers(cb) {
91+
return this._request('GET', this.__getScopedUrl('followers'), null, cb);
92+
}
93+
94+
/**
95+
* List users followed by another user
96+
* @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
97+
* @param {Requestable.callback} [cb] - will receive the list of who a user is following
98+
* @return {Promise} - the promise for the http request
99+
*/
100+
listFollowing(cb) {
101+
return this._request('GET', this.__getScopedUrl('following'), null, cb);
102+
}
103+
84104
/**
85105
* List the user's gists
86106
* @see https://developer.github.com/v3/gists/#list-a-users-gists
@@ -132,6 +152,23 @@ class User extends Requestable {
132152
return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb);
133153
}
134154

155+
/**
156+
* Gets the list of starred gists for the user
157+
* @see https://developer.github.com/v3/gists/#list-starred-gists
158+
* @param {Object} [options={}] - any options to refine the search
159+
* @param {Requestable.callback} [cb] - will receive the list of gists
160+
* @return {Promise} - the promise for the http request
161+
*/
162+
listStarredGists(options, cb) {
163+
options = options || {};
164+
if (typeof options === 'function') {
165+
cb = options;
166+
options = {};
167+
}
168+
options.since = this._dateToISO(options.since);
169+
return this._request('GET', '/gists/starred', options, cb);
170+
}
171+
135172
/**
136173
* List email addresses for a user
137174
* @see https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-api",
3-
"version": "3.1.0",
3+
"version": "3.2.1",
44
"license": "BSD-3-Clause-Clear",
55
"description": "A higher-level wrapper around the Github API.",
66
"main": "dist/components/GitHub.js",
@@ -52,7 +52,7 @@
5252
"dist/*"
5353
],
5454
"dependencies": {
55-
"axios": "^0.15.2",
55+
"axios": "^0.19.0",
5656
"debug": "^2.2.0",
5757
"js-base64": "^2.1.9",
5858
"utf8": "^2.1.1"

test/dist.spec/index.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<script>mocha.setup('bdd')</script>
1313
<script>
1414
describe('the dist file', function() {
15-
it('should work', function(done) {
15+
it('should load a Gist', function(done) {
1616
var github = new GitHub();
1717
var gist = github.getGist('e265df71e7532f3a4bdd');
1818
gist.read()
@@ -21,6 +21,24 @@
2121
done();
2222
});
2323
});
24+
25+
it('should render markdown', function(done) {
26+
var shouldBe = '<p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>\n';
27+
var github = new GitHub();
28+
var markdown = github.getMarkdown();
29+
const options = {
30+
text: 'Hello world github/linguist#1 **cool**, and #1!',
31+
};
32+
33+
markdown.render(options)
34+
.then(function({data: html}) {
35+
console.log(html);
36+
if (html !== shouldBe) {
37+
throw new Error(html + ' should be ' + shouldBe)
38+
}
39+
done();
40+
}).catch(done);
41+
});
2442
});
2543
</script>
2644
<script>

test/markdown.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Markdown', function() {
3737
};
3838
markdown.render(options)
3939
.then(function({data: html}) {
40-
expect(html).to.be('<p>Hello world <a href="https://github.com/github/linguist/issues/1" class="issue-link js-issue-link" data-url="https://github.com/github/linguist/issues/1" data-id="1012654" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">github/linguist#1</a> <strong>cool</strong>, and <a href="https://github.com/gollum/gollum/issues/1" class="issue-link js-issue-link" data-url="https://github.com/gollum/gollum/issues/1" data-id="183433" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#1</a>!</p>'); // eslint-disable-line
40+
expect(html).to.be('<p>Hello world <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="1012654" data-permission-text="Issue title is private" data-url="https://github.com/github/linguist/issues/1" data-hovercard-type="issue" data-hovercard-url="/github/linguist/issues/1/hovercard" href="https://github.com/github/linguist/issues/1">github/linguist#1</a> <strong>cool</strong>, and <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="183433" data-permission-text="Issue title is private" data-url="https://github.com/gollum/gollum/issues/1" data-hovercard-type="issue" data-hovercard-url="/gollum/gollum/issues/1/hovercard" href="https://github.com/gollum/gollum/issues/1">gollum#1</a>!</p>'); // eslint-disable-line
4141
done();
4242
}).catch(done);
4343
});

0 commit comments

Comments
 (0)