From 2765a3c2afc8721a4f6b021cb283e28289f5b1df Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 31 Dec 2016 03:35:19 +0900 Subject: [PATCH] Extract EnvironmentInfo --- src/index.ts | 14 ++------------ src/utils/environmentInfo.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/utils/environmentInfo.ts diff --git a/src/index.ts b/src/index.ts index d53e695dcd..2118234188 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ const isRoot = require('is-root'); import ProgressBar from './utils/cli/progressbar'; import initdb from './db/mongodb'; import LastCommitInfo from './utils/lastCommitInfo'; +import EnvironmentInfo from './utils/environmentInfo'; import MachineInfo from './utils/machineInfo'; import DependencyInfo from './utils/dependencyInfo'; @@ -24,10 +25,6 @@ import DependencyInfo from './utils/dependencyInfo'; require('babel-core/register'); require('babel-polyfill'); -const env = process.env.NODE_ENV; -const IS_PRODUCTION = env === 'production'; -const IS_DEBUG = !IS_PRODUCTION; - global.config = require('./config').default(`${__dirname}/../.config/config.yml`); /** @@ -138,14 +135,7 @@ async function init(): Promise { Logger.info('Initializing...'); await LastCommitInfo.show(); - - let envLogger = new Logger('Env'); - envLogger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`); - if (IS_DEBUG) { - envLogger.warn('The environment is not in production mode'); - envLogger.warn('Do not use for production purpose'); - } - + EnvironmentInfo.show(); MachineInfo.show(); new DependencyInfo().showAll(); diff --git a/src/utils/environmentInfo.ts b/src/utils/environmentInfo.ts new file mode 100644 index 0000000000..435bc9f49a --- /dev/null +++ b/src/utils/environmentInfo.ts @@ -0,0 +1,13 @@ +import Logger from './logger'; + +export default class EnvironmentInfo { + static show(): void { + const env = process.env.NODE_ENV; + let logger = new Logger('Env'); + logger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`); + if (env !== 'production') { + logger.warn('The environment is not in production mode'); + logger.warn('Do not use for production purpose'); + } + } +}