Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit a7ea456

Browse files
committed
initialize: Report in header the scope of the current project
1 parent 713e1e5 commit a7ea456

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,6 @@ any):
323323
the CI environment variable to be set to `true`. Also accepted are the
324324
existence of the `JENKINS_URL`, `bamboo.buildKey` and `TDDIUM` environment
325325
variables.
326+
* `scope` {String} The scope of the project this command is being run for. This is the
327+
top level npm module in which a command was run.
328+
Default = none

lib/initialize.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ function initialize (uri, method, accept, headers) {
5454
headers['npm-session'] = this.config.sessionToken
5555
headers['npm-in-ci'] = String(this.config.isFromCI)
5656
headers['user-agent'] = this.config.userAgent
57+
if (this.config.scope) {
58+
headers['npm-scope'] = this.config.scope
59+
}
5760

5861
return opts
5962
}

test/config-override.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var config = {
2626
couchToken: { object: true },
2727
sessionToken: 'hamchunx',
2828
isFromCI: true
29+
sessionToken: 'hamchunx',
30+
scope: '@test'
2931
}
3032

3133
test('config defaults', function (t) {
@@ -54,6 +56,7 @@ test('config defaults', function (t) {
5456
t.ok(client.config.couchToken.object)
5557
t.equal(client.config.sessionToken, 'hamchunx')
5658
t.ok(client.config.isFromCI)
59+
t.is(client.config.scope, '@test')
5760

5861
t.end()
5962
})

0 commit comments

Comments
 (0)