From 7b177e43f3bfb558bcd8723cdb2166a3df19647a Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 1 Apr 2021 10:06:33 -0700 Subject: Add a 'envExport' flag for config definitions It defaults to true, but setting it to any falsey value will tell `@npmcli/config` not to export it into the environment, and will also put a remark in the documentation that it is not exported. PR-URL: https://github.com/npm/cli/pull/3014 Credit: @isaacs Close: #3014 Reviewed-by: @nlf --- test/lib/utils/config/definition.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/lib/utils/config/definition.js b/test/lib/utils/config/definition.js index 88a527db6..45f4c977a 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 ', typeDescription: 'Number or String', description: 'just a test thingie', + envExport: true, }) t.matchSnapshot(def.describe(), 'human-readable description') @@ -119,6 +120,25 @@ t.test('basic definition', async t => { description: 'asdf', }) t.equal(optionalBool.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 => { -- cgit v1.2.3