Skip to content

Commit

Permalink
Check the presence of process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed Jan 9, 2020
1 parent d42843e commit be1f921
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/warning/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function isDev() {
return (
typeof process !== 'undefined' &&
process.env &&
process.env.NODE_ENV !== 'production'
);
}

/**
* Shows a warning with `messages` if `condition` passes and environment is not `production`.
*
Expand All @@ -15,7 +23,7 @@
* ```
*/
export default function warning( condition, ...messages ) {
if ( process.env.NODE_ENV !== 'production' ) {
if ( isDev() ) {
if ( ! condition ) {
return;
}
Expand Down

0 comments on commit be1f921

Please sign in to comment.