diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70a14131..003dc8b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+## [8.1.0](https://github.com/npm/registry-fetch/compare/v8.0.3...v8.1.0) (2020-05-20)
+
+
+### Features
+
+* add npm-command HTTP header ([1bb4eb2](https://github.com/npm/registry-fetch/commit/1bb4eb2c66ee8a0dc62558bdcff1b548e2bb9820))
+
### [8.0.3](https://github.com/npm/registry-fetch/compare/v8.0.2...v8.0.3) (2020-05-13)
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/package-lock.json b/package-lock.json
index bb9603ab..3f630b51 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "npm-registry-fetch",
- "version": "8.0.3",
+ "version": "8.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 14379de6..42170071 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "npm-registry-fetch",
- "version": "8.0.3",
+ "version": "8.1.0",
"description": "Fetch-based http client for use with npm registry APIs",
"main": "index.js",
"files": [
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')
})