diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index cfce5396f40a7..b0f365f293dfc 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -1333,6 +1333,8 @@ Valid values for the `workspace` config are either: - Workspace names - Path to a workspace directory - Path to a parent workspace directory (will result to selecting all of the nested workspaces) +This value is not exported to the environment for child processes. + #### `workspaces` * Default: false @@ -1341,6 +1343,8 @@ to selecting all of the nested workspaces) Enable running a command in the context of **all** the configured workspaces. +This value is not exported to the environment for child processes. + #### `yes` * Default: null diff --git a/lib/utils/config/definition.js b/lib/utils/config/definition.js index cb4eb78210c6e..9ab3c8442605e 100644 --- a/lib/utils/config/definition.js +++ b/lib/utils/config/definition.js @@ -25,6 +25,7 @@ const allowed = [ 'type', 'typeDescription', 'usage', + 'envExport', ] const { @@ -39,6 +40,8 @@ const { class Definition { constructor (key, def) { this.key = key + // if it's set falsey, don't export it, otherwise we do by default + this.envExport = true Object.assign(this, def) this.validate() if (!this.defaultDescription) @@ -67,6 +70,9 @@ class Definition { // a textual description of this config, suitable for help output describe () { const description = unindent(this.description) + const noEnvExport = this.envExport ? '' : ` +This value is not exported to the environment for child processes. +` const deprecated = !this.deprecated ? '' : `* DEPRECATED: ${unindent(this.deprecated)}\n` return wrapAll(`#### \`${this.key}\` @@ -75,7 +81,7 @@ class Definition { * Type: ${unindent(this.typeDescription)} ${deprecated} ${description} -`) +${noEnvExport}`) } } diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index db66aa495ba0f..766705f1a5276 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -2043,6 +2043,7 @@ define('workspace', { default: [], type: [String, Array], short: 'w', + envExport: false, description: ` Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by @@ -2060,6 +2061,7 @@ define('workspaces', { default: false, type: Boolean, short: 'ws', + envExport: false, description: ` Enable running a command in the context of **all** the configured workspaces. diff --git a/tap-snapshots/test-lib-utils-config-describe-all.js-TAP.test.js b/tap-snapshots/test-lib-utils-config-describe-all.js-TAP.test.js index 2a3d0146b187d..91b30fbb90e9b 100644 --- a/tap-snapshots/test-lib-utils-config-describe-all.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-config-describe-all.js-TAP.test.js @@ -1212,6 +1212,8 @@ Valid values for the \`workspace\` config are either: - Workspace names - Path to a workspace directory - Path to a parent workspace directory (will result to selecting all of the nested workspaces) +This value is not exported to the environment for child processes. + #### \`workspaces\` * Default: false @@ -1220,6 +1222,8 @@ to selecting all of the nested workspaces) Enable running a command in the context of **all** the configured workspaces. +This value is not exported to the environment for child processes. + #### \`yes\` * Default: null diff --git a/test/lib/utils/config/definition.js b/test/lib/utils/config/definition.js index 56e10da0cbd7d..362286dd1fb83 100644 --- a/test/lib/utils/config/definition.js +++ b/test/lib/utils/config/definition.js @@ -25,6 +25,7 @@ t.test('basic definition', async t => { usage: '--key |--key ', typeDescription: 'Number or String', description: 'just a test thingie', + envExport: true, }) t.matchSnapshot(def.describe(), 'human-readable description') @@ -113,6 +114,25 @@ t.test('basic definition', async t => { hint: '', }) t.equal(hasHint.usage, '--key ') + + const noExported = new Definition('methane', { + envExport: false, + type: String, + typeDescription: 'Greenhouse Gas', + default: 'CH4', + description: ` + This is bad for the environment, for our children, do not put it there. + `, + }) + t.equal(noExported.envExport, false, 'envExport flag is false') + t.equal(noExported.describe(), `#### \`methane\` + +* Default: "CH4" +* Type: Greenhouse Gas + +This is bad for the environment, for our children, do not put it there. + +This value is not exported to the environment for child processes.`) }) t.test('missing fields', async t => {