Skip to content

Commit

Permalink
fix(config): accept explicit production=false
Browse files Browse the repository at this point in the history
This allows for overriding the implicit omit value based on if
NODE_ENV=production

PR-URL: #2951
Credit: @wraithgar
Close: #2951
Reviewed-by: @ruyadorno
  • Loading branch information
wraithgar authored and ruyadorno committed Mar 24, 2021
1 parent 7b45e9d commit 200bee7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const buildOmitList = obj => {
const only = obj.only
if (/^prod(uction)?$/.test(only) || obj.production)
omit.push('dev')
else if (obj.production === false)
include.push('dev')

if (/^dev/.test(obj.also))
include.push('dev')
Expand Down Expand Up @@ -1396,8 +1398,8 @@ define('preid', {
})

define('production', {
default: false,
type: Boolean,
default: null,
type: [null, Boolean],
deprecated: 'Use `--omit=dev` instead.',
description: 'Alias for `--omit=dev`',
flatten (key, obj, flatOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,8 @@ Alias for --include=optional or --omit=optional
#### \`production\`
* Default: false
* Type: Boolean
* Default: null
* Type: null or Boolean
* DEPRECATED: Use \`--omit=dev\` instead.
Alias for \`--omit=dev\`
Expand Down
4 changes: 2 additions & 2 deletions test/lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ t.test('flatteners that populate flat.omit array', t => {
definitions.production.flatten('production', obj, flat)
t.strictSame(obj, {
production: false,
include: [],
include: ['dev'],
omit: [],
}, '--no-production has no effect')
}, '--no-production explicitly includes dev')
t.strictSame(flat, { omit: [] }, '--no-production has no effect')

obj.production = true
Expand Down

0 comments on commit 200bee7

Please sign in to comment.