1+ // MIT License
2+ //
3+ // Copyright (c) 2017-2019 Stefano Cappa
4+ //
5+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6+ // of this software and associated documentation files (the "Software"), to deal
7+ // in the Software without restriction, including without limitation the rights
8+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ // copies of the Software, and to permit persons to whom the Software is
10+ // furnished to do so, subject to the following conditions:
11+ //
12+ // The above copyright notice and this permission notice shall be included in all
13+ // copies or substantial portions of the Software.
14+ //
15+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+ // SOFTWARE.
22+
123'use strict' ;
224
325const path = require ( 'path' ) ;
426
5- const useDotenv = process . env . CI !== 'yes' && process . env . CI !== true ;
6- console . log ( `Use dotenv condition is: ${ useDotenv } ` ) ;
27+ const notInCI = process . env . CI !== 'yes' && process . env . CI !== true ;
28+ console . log ( `Use dotenv condition is: ${ notInCI } , because I cannot use dotenv with CI, so I have to skip it ` ) ;
729
8- if ( useDotenv === true ) {
30+ if ( notInCI === true ) {
931 console . log ( 'Initializing dotenv (requires .env/.env_prod file)' ) ;
1032 let dotenvName = null ;
1133 switch ( process . env . NODE_ENV ) {
1234 case 'development' :
13- console . log ( 'dotenv read: .env_dev ' ) ;
14- dotenvName = '.env_dev ' ;
35+ console . log ( 'dotenv read: .env ' ) ;
36+ dotenvName = '.env ' ;
1537 break ;
1638 case 'test' :
17- console . log ( 'dotenv read: .env_dev (you are running with NODE_ENV=test)' ) ;
18- dotenvName = '.env_dev ' ;
39+ console . log ( 'dotenv read: .env (you are running with NODE_ENV=test)' ) ;
40+ dotenvName = '.env ' ;
1941 break ;
2042 default :
2143 case 'production' :
@@ -41,8 +63,10 @@ if (useDotenv === true) {
4163module . exports = {
4264 isProd : ( ) => process . env . NODE_ENV === 'production' ,
4365 isTest : ( ) => process . env . NODE_ENV === 'test' ,
66+ isCI : ( ) => process . env . CI === 'yes' || process . env . CI === true ,
4467
4568 NODE_ENV : process . env . NODE_ENV || 'development' ,
69+ CI : process . env . CI || 'yes' ,
4670
4771 FRONT_END_PATH : process . env . FRONT_END_PATH ,
4872 PORT : process . env . PORT || process . env . NODE_ENV === 'production' ? 80 : 3000 ,
0 commit comments