Content-Length: 350735 | pFad | http://github.com/npm/npm-registry-client/commit/8adacaef07abcb8cfcc7bd0521c0d43b28ab9f0a

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

Commit 8adacae

Browse files
committed
initialize: Report in header if we're in CI
1 parent 0b595c4 commit 8adacae

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

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

lib/initialize.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ 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(process.env['CI'] === 'true' || process.env['TDDIUM'] || process.env['JENKINS_URL'] || process.env['bamboo.buildKey'])
16+
}
1417

1518
var opts = {
1619
url: uri,
@@ -47,6 +50,7 @@ function initialize (uri, method, accept, headers) {
4750
if (this.refer) headers.referer = this.refer
4851

4952
headers['npm-session'] = this.config.sessionToken
53+
headers['npm-in-ci'] = String(this.config.isFromCI)
5054
headers['user-agent'] = this.config.userAgent
5155

5256
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/8adacaef07abcb8cfcc7bd0521c0d43b28ab9f0a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy