File tree 1 file changed +28
-2
lines changed
1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -79,18 +79,44 @@ exports.commitHash =
79
79
process . env . GIT_COMMIT ||
80
80
null ;
81
81
82
+ /**
83
+ * Normalize environment tag
84
+ * @param {string } tag
85
+ * The environment tag to normalize.
86
+ * @returns {string }
87
+ * Returns the normalized environment tag
88
+ */
89
+ function normalizeEnvironmentTag ( tag ) {
90
+ const tagLower = tag . toLowerCase ( ) ;
91
+
92
+ if ( [ 'd' , 'dev' , 'development' ] . includes ( tagLower ) ) {
93
+ return 'development' ;
94
+ }
95
+
96
+ if ( [ 't' , 'test' ] . includes ( tagLower ) ) {
97
+ return 'test' ;
98
+ }
99
+
100
+ if ( [ 'p' , 'prod' , 'production' ] . includes ( tagLower ) ) {
101
+ return 'production' ;
102
+ }
103
+
104
+ return tag ;
105
+ }
106
+
82
107
/**
83
108
* The application deployment environment.
84
109
*
85
110
* @readonly
86
111
* @type {string }
87
112
*/
88
- exports . environment =
113
+ exports . environment = normalizeEnvironmentTag (
89
114
process . env . DEPLOYMENT_ENVIRONMENT ||
90
115
process . env . RELEASE_ENV ||
91
116
process . env . ENVIRONMENT ||
92
117
process . env . NODE_ENV ||
93
- 'development' ;
118
+ 'development'
119
+ ) ;
94
120
95
121
/**
96
122
* The region the application is running in.
You can’t perform that action at this time.
0 commit comments