Extract EnvironmentInfo
This commit is contained in:
parent
eb10c3a8dc
commit
2765a3c2af
2 changed files with 15 additions and 12 deletions
14
src/index.ts
14
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<State> {
|
|||
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();
|
||||
|
||||
|
|
13
src/utils/environmentInfo.ts
Normal file
13
src/utils/environmentInfo.ts
Normal file
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue