Content-Length: 356950 | pFad | http://github.com/npm/npm-registry-client/commit/713e1e51fbf8d163c8edc5dc8cbdf626c3996547

B1 initialize: Report in header if we're in CI · npm/npm-registry-client@713e1e5 · GitHub
Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 713e1e5

Browse files
committed
initialize: Report in header if we're in CI
1 parent debec76 commit 713e1e5

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,8 @@ any):
318318
origen (unique combination of protocol:host:port). Passed to the
319319
[httpAgent](https://nodejs.org/api/http.html#http_agent_maxsockets).
320320
Default = 50
321+
* `isFromCI` {Boolean} Identify to severs if this request is coming from CI (for statistics purposes).
322+
Default = detected from environment– primarily this is done by looking for
323+
the CI environment variable to be set to `true`. Also accepted are the
324+
existence of the `JENKINS_URL`, `bamboo.buildKey` and `TDDIUM` environment
325+
variables.

lib/initialize.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ function initialize (uri, method, accept, headers) {
1111
this.config.sessionToken = crypto.randomBytes(8).toString('hex')
1212
this.log.verbose('request id', this.config.sessionToken)
1313
}
14+
if (this.config.isFromCI == null) {
15+
this.config.isFromCI = Boolean(
16+
process.env['CI'] === 'true' || process.env['TDDIUM'] ||
17+
process.env['JENKINS_URL'] || process.env['bamboo.buildKey'])
18+
}
1419

1520
var opts = {
1621
url: uri,
@@ -47,6 +52,7 @@ function initialize (uri, method, accept, headers) {
4752
if (this.refer) headers.referer = this.refer
4853

4954
headers['npm-session'] = this.config.sessionToken
55+
headers['npm-in-ci'] = String(this.config.isFromCI)
5056
headers['user-agent'] = this.config.userAgent
5157

5258
return opts

test/config-override.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var config = {
2424
log: { fake: function () {} },
2525
defaultTag: 'next',
2626
couchToken: { object: true },
27-
sessionToken: 'hamchunx'
27+
sessionToken: 'hamchunx',
28+
isFromCI: true
2829
}
2930

3031
test('config defaults', function (t) {
@@ -52,6 +53,7 @@ test('config defaults', function (t) {
5253
t.equal(client.config.defaultTag, 'next')
5354
t.ok(client.config.couchToken.object)
5455
t.equal(client.config.sessionToken, 'hamchunx')
56+
t.ok(client.config.isFromCI)
5557

5658
t.end()
5759
})

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/npm/npm-registry-client/commit/713e1e51fbf8d163c8edc5dc8cbdf626c3996547

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy