Skip to content

Commit

Permalink
allow for passing object keys to searchopts to allow pagination
Browse files Browse the repository at this point in the history
PR-URL: #2303
Credit: @nlf
Close: #2303
Reviewed-by: @isaacs
  • Loading branch information
nlf authored and isaacs committed Dec 8, 2020
1 parent 0ef25b6 commit 3db90d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const log = require('npmlog')
const crypto = require('crypto')
const querystring = require('querystring')
const npmSession = crypto.randomBytes(8).toString('hex')
log.verbose('npm-session', npmSession)
const { join } = require('path')
Expand Down Expand Up @@ -92,7 +93,7 @@ const flatten = obj => ({
description: obj.description,
exclude: obj.searchexclude,
limit: obj.searchlimit || 20,
opts: obj.searchopts,
opts: querystring.parse(obj.searchopts),
staleness: obj.searchstaleness,
},

Expand Down
4 changes: 3 additions & 1 deletion tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ Object {
"description": "description",
"exclude": "searchexclude",
"limit": "searchlimit",
"opts": "searchopts",
"opts": Null Object {
"from": "1",
},
"staleness": "searchstaleness",
},
"sendMetrics": "send-metrics",
Expand Down
2 changes: 1 addition & 1 deletion test/lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MockConfig {
description: 'description',
searchexclude: 'searchexclude',
searchlimit: 'searchlimit',
searchopts: 'searchopts',
searchopts: 'from=1',
searchstaleness: 'searchstaleness',
'dry-run': 'dry-run',
'engine-strict': 'engine-strict',
Expand Down

0 comments on commit 3db90d9

Please sign in to comment.