import path = require('path')

const isInTSNODE = typeof process[Symbol.for('ts-node.register.instance')] !== 'undefined'
const _env = process.env
/** 当前运行期的环境变量 */
export const env = _env.SERVER_ENV || _env.NODE_ENV

/** 项目的根目录绝对路径 */
export const ROOT = path.resolve(__dirname, '../../')
/** 项目的 app 目录绝对路径 */
export const APP = path.resolve(ROOT, isInTSNODE ? 'src' : 'dist')

export const isInTsNode = isInTSNODE

const win = process.platform === 'win32'
const home = (win ? process.env.USERPROFILE : process.env.HOME) || __dirname

export const STORAGE_DIR = path.resolve(home, '.gem-mine')