diff options
author | nlf <quitlahok@gmail.com> | 2021-05-04 19:19:31 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-05-06 22:46:31 +0300 |
commit | d84b1bd23244c80a49cc9d3edef56b5a102f7c36 (patch) | |
tree | 56bbc5f747b0dc52c1c0e4c905ce9a4a74f570fa /lib | |
parent | 2c9b8713c4c88fbd0c3c48eb0de84dbd7269398f (diff) |
feat(config): add workspaces boolean to user-agent
PR-URL: https://github.com/npm/cli/pull/3187
Credit: @nlf
Close: #3187
Reviewed-by: @wraithgar
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/config/definitions.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 3a50175d5..aa90de8e7 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -1943,6 +1943,7 @@ define('user-agent', { 'node/{node-version} ' + '{platform} ' + '{arch} ' + + 'workspaces/{workspaces} ' + '{ci}', type: String, description: ` @@ -1953,17 +1954,23 @@ define('user-agent', { * \`{node-version}\` - The Node.js version in use * \`{platform}\` - The value of \`process.platform\` * \`{arch}\` - The value of \`process.arch\` + * \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\` + options are set. * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with \`ci/\`, or an empty string if \`ci-name\` is empty. `, flatten (key, obj, flatOptions) { const value = obj[key] const ciName = obj['ci-name'] + let inWorkspaces = false + if (obj.workspaces || obj.workspace && obj.workspace.length) + inWorkspaces = true flatOptions.userAgent = value.replace(/\{node-version\}/gi, obj['node-version']) .replace(/\{npm-version\}/gi, obj['npm-version']) .replace(/\{platform\}/gi, process.platform) .replace(/\{arch\}/gi, process.arch) + .replace(/\{workspaces\}/gi, inWorkspaces) .replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '') .trim() // user-agent is a unique kind of config item that gets set from a template |