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

Commit 77771d4

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

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ var config = {
2525
defaultTag: 'next',
2626
couchToken: { object: true },
2727
sessionToken: 'hamchunx',
28-
isFromCI: true
28+
isFromCI: true,
29+
scope: '@test'
2930
}
3031

3132
test('config defaults', function (t) {
@@ -54,6 +55,7 @@ test('config defaults', function (t) {
5455
t.ok(client.config.couchToken.object)
5556
t.equal(client.config.sessionToken, 'hamchunx')
5657
t.ok(client.config.isFromCI)
58+
t.is(client.config.scope, '@test')
5759

5860
t.end()
5961
})

0 commit comments

Comments
 (0)