diff --git a/README.md b/README.md
index 499d4f98..e660940e 100644
--- a/README.md
+++ b/README.md
@@ -398,6 +398,15 @@ If provided, will be sent in the `npm-session` header. This header is used by
the npm registry to identify individual user sessions (usually individual
invocations of the CLI).
+##### `opts.npmCommand`
+
+* Type: String
+* Default: null
+
+If provided, it will be sent in the `npm-command` header. This yeader is
+used by the npm registry to identify the npm command that caused this
+request to be made.
+
##### `opts.offline`
* Type: Boolean
diff --git a/index.js b/index.js
index 8e05f418..eb48ba6c 100644
--- a/index.js
+++ b/index.js
@@ -186,6 +186,10 @@ function getHeaders (registry, uri, opts) {
headers['npm-session'] = opts.npmSession
}
+ if (opts.npmCommand) {
+ headers['npm-command'] = opts.npmCommand
+ }
+
const auth = getAuth(registry, opts)
// If a tarball is hosted on a different place than the manifest, only send
// credentials on `alwaysAuth`
diff --git a/test/index.js b/test/index.js
index 5ad69170..339efa19 100644
--- a/test/index.js
+++ b/test/index.js
@@ -494,10 +494,6 @@ test('npm-in-ci header with forced CI=false', t => {
})
})
-// TODO
-// * npm-session
-// * npm-scope
-// * user-agent
test('miscellaneous headers', t => {
tnock(t, OPTS.registry)
.matchHeader('npm-session', session =>
@@ -508,6 +504,8 @@ test('miscellaneous headers', t => {
t.strictSame(ua, ['agent of use'], 'UA set from options'))
.matchHeader('npm-in-ci', ci =>
t.strictSame(ci, ['false'], 'CI set from options'))
+ .matchHeader('npm-command', cmd =>
+ t.strictSame(cmd, ['hello-world'], 'command set from options'))
.get('/hello')
.reply(200, { hello: 'world' })
@@ -515,7 +513,8 @@ test('miscellaneous headers', t => {
...OPTS,
npmSession: 'foobarbaz',
projectScope: '@foo',
- userAgent: 'agent of use'
+ userAgent: 'agent of use',
+ npmCommand: 'hello-world'
}).then(res => {
t.equal(res.status, 200, 'got successful response')
})