File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed
Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,18 @@ export class Logger {
2525 * @default 'react-fontawesome'
2626 */
2727 scope = 'react-fontawesome' ,
28- /**
29- * Whether to log messages from this Logger instance in production.
30- * @default false
31- */
32- shouldLogInProduction = false ,
3328 ) {
29+ let IS_DEV = false
30+
31+ try {
32+ IS_DEV =
33+ typeof process !== 'undefined' && process . env . NODE_ENV === 'development'
34+ } catch {
35+ // Do nothing.
36+ }
37+
3438 this . scope = scope
35- this . enabled =
36- shouldLogInProduction || process . env . NODE_ENV !== 'production'
39+ this . enabled = ! IS_DEV
3740 }
3841
3942 /**
Original file line number Diff line number Diff line change @@ -29,23 +29,17 @@ describe('Logger', () => {
2929 expect ( logger . scope ) . toBe ( 'custom-scope' )
3030 } )
3131
32- it ( 'should be enabled by default in non-production' , ( ) => {
32+ it ( 'should be enabled in non-production' , ( ) => {
3333 process . env . NODE_ENV = 'development'
3434 const logger = new Logger ( )
3535 expect ( logger . enabled ) . toBe ( true )
3636 } )
3737
38- it ( 'should be disabled by default in production' , ( ) => {
38+ it ( 'should be disabled in production' , ( ) => {
3939 process . env . NODE_ENV = 'production'
4040 const logger = new Logger ( )
4141 expect ( logger . enabled ) . toBe ( false )
4242 } )
43-
44- it ( 'should be enabled in production when shouldLogInProduction is true' , ( ) => {
45- process . env . NODE_ENV = 'production'
46- const logger = new Logger ( 'test' , true )
47- expect ( logger . enabled ) . toBe ( true )
48- } )
4943 } )
5044
5145 describe ( 'log method' , ( ) => {
Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ import semver from 'semver'
88
99export const ICON_PACKS_STARTING_VERSION = '7.0.0-alpha1'
1010
11+ const FA_VERSION =
12+ ( typeof process !== 'undefined' && process . env . FA_VERSION ) || '7.0.0-alpha8'
13+
1114// Try to get version from installed package first, fallback to env var, then default
12- export const SVG_CORE_VERSION =
13- SVGCorePackageVersion || process . env . FA_VERSION || '7.0.0-alpha8'
15+ export const SVG_CORE_VERSION = SVGCorePackageVersion || FA_VERSION
1416
1517// Cache the version check result since it never changes during runtime
1618export const IS_VERSION_7_OR_LATER = semver . gte (
You can’t perform that action at this time.
0 commit comments