-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE_ENV를 한번만 로드하고 사용할 수 있도록 수정 - 중복 코드 제거 Refactor: refactor get NODE_ENV Refactor: refactor get NODE_ENV
- Loading branch information
Showing
3 changed files
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import { resolve } from 'path'; | ||
import { InternalServerErrorException } from '@nestjs/common'; | ||
|
||
import { NODE_ENVIRONMENT } from './env.validation'; | ||
|
||
export const getEnvPath = (dest: string): string => { | ||
const env: string = process.env.NODE_ENV; | ||
|
||
if (env == nodeEnvironment.staging || env == nodeEnvironment.production) { | ||
return undefined; | ||
} | ||
|
||
const filename: string = env ? `.${env}.env` : '.development.env'; | ||
return resolve(`${dest}/${filename}`); | ||
}; | ||
|
||
export const ignoreEnvFile = ((): boolean => { | ||
export const getNodeEnv = (() => { | ||
const env = process.env.NODE_ENV; | ||
return env === NODE_ENVIRONMENT.stage || env === NODE_ENVIRONMENT.production; | ||
const nodeEnv = NODE_ENVIRONMENT[env]; | ||
if (nodeEnv === undefined) { | ||
throw new InternalServerErrorException('Unknown NODE_ENV'); | ||
} | ||
return nodeEnv; | ||
})(); | ||
|
||
export const isIgnoreEnvFile = | ||
getNodeEnv === NODE_ENVIRONMENT.stage || | ||
getNodeEnv === NODE_ENVIRONMENT.production; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters