File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed
fixtures/lots-of-contributors Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ const cli = meow(
11
11
12
12
Options
13
13
--exclude, -e Exclude contributors, glob.
14
+ --limit, -l Limit the number of contributors (default: 30).
14
15
15
16
Examples
16
17
$ contributor-faces --exclude "*-bot"
17
18
` ,
18
19
{
19
20
alias : {
20
21
e : 'exclude' ,
22
+ l : 'limit'
21
23
}
22
24
}
23
25
)
Original file line number Diff line number Diff line change
1
+ {
2
+ "repository" : " facebook/react"
3
+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ function getRepo(baton) {
18
18
}
19
19
20
20
function fetch ( baton ) {
21
- return gh ( `repos/${ baton . repo } /contributors` ) . then ( res => {
21
+ const searchParams = {
22
+ [ 'per_page' ] : baton . limit
23
+ }
24
+
25
+ return gh ( `repos/${ baton . repo } /contributors` , { searchParams } ) . then ( res => {
22
26
baton . contributors = res . body
23
27
return baton
24
28
} )
@@ -77,6 +81,7 @@ function end(prop) {
77
81
function core ( dir , opts ) {
78
82
opts = opts || { }
79
83
opts . dir = dir || '.'
84
+ opts . limit = opts . limit || 30
80
85
return Promise . resolve ( opts ) . then ( getRepo ) . then ( fetch ) . then ( filter )
81
86
}
82
87
Original file line number Diff line number Diff line change @@ -10,6 +10,20 @@ test('list contributors', async t => {
10
10
t . true ( Array . isArray ( contribs ) )
11
11
} )
12
12
13
+ test ( 'limit contributors to 30 by default' , async t => {
14
+ const repoDir = path . join ( 'fixtures' , 'lots-of-contributors' )
15
+ const contribs = await contributors ( repoDir )
16
+
17
+ t . is ( contribs . length , 30 )
18
+ } )
19
+
20
+ test ( 'accept a limit parameter' , async t => {
21
+ const repoDir = path . join ( 'fixtures' , 'lots-of-contributors' )
22
+ const contribs = await contributors ( repoDir , { limit : 100 } )
23
+
24
+ t . is ( contribs . length , 100 )
25
+ } )
26
+
13
27
test . serial ( 'use current directory by default' , async t => {
14
28
process . chdir ( 'fixtures' )
15
29
const contribs = await contributors ( )
You can’t perform that action at this time.
0 commit comments