Skip to content

Commit 200bee7

Browse files
wraithgarruyadorno
authored andcommitted
fix(config): accept explicit production=false
This allows for overriding the implicit omit value based on if NODE_ENV=production PR-URL: #2951 Credit: @wraithgar Close: #2951 Reviewed-by: @ruyadorno
1 parent 7b45e9d commit 200bee7

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/utils/config/definitions.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const buildOmitList = obj => {
2929
const only = obj.only
3030
if (/^prod(uction)?$/.test(only) || obj.production)
3131
omit.push('dev')
32+
else if (obj.production === false)
33+
include.push('dev')
3234

3335
if (/^dev/.test(obj.also))
3436
include.push('dev')
@@ -1396,8 +1398,8 @@ define('preid', {
13961398
})
13971399

13981400
define('production', {
1399-
default: false,
1400-
type: Boolean,
1401+
default: null,
1402+
type: [null, Boolean],
14011403
deprecated: 'Use `--omit=dev` instead.',
14021404
description: 'Alias for `--omit=dev`',
14031405
flatten (key, obj, flatOptions) {

tap-snapshots/test-lib-utils-config-describe-all.js-TAP.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,8 @@ Alias for --include=optional or --omit=optional
13381338
13391339
#### \`production\`
13401340
1341-
* Default: false
1342-
* Type: Boolean
1341+
* Default: null
1342+
* Type: null or Boolean
13431343
* DEPRECATED: Use \`--omit=dev\` instead.
13441344
13451345
Alias for \`--omit=dev\`

test/lib/utils/config/definitions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ t.test('flatteners that populate flat.omit array', t => {
310310
definitions.production.flatten('production', obj, flat)
311311
t.strictSame(obj, {
312312
production: false,
313-
include: [],
313+
include: ['dev'],
314314
omit: [],
315-
}, '--no-production has no effect')
315+
}, '--no-production explicitly includes dev')
316316
t.strictSame(flat, { omit: [] }, '--no-production has no effect')
317317

318318
obj.production = true

0 commit comments

Comments
 (0)