import chalk from 'chalk';
import logSymbols from 'log-symbols';
import moment from 'moment';

global.fs = require('fs-extra');
global.sysPath = require('path');

global.ENV = {
  LOC: 'location', // 本地
  DEV: 'development', // 开发dev的时候
  PRD: 'production' // 线上
}

global.USER_HOME = process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'];
global.FET_RC = sysPath.join(USER_HOME, '.fetrc');

global.info = console.info;

global.success = function() {
  info(chalk.green(' √ ' + [].slice.call(arguments).join(' ')));
};

global.warn = function() {
  info(chalk.yellow(' ∆ ' + [].slice.call(arguments).join(' ')));
};

global.error = function() {
  info(chalk.bold.red(' X '), chalk.bold.red([].slice.call(arguments).join(' ')));
};

global.log = function() {
  console.log(chalk.cyan('[fet] '), [].slice.call(arguments).join(' '));
};

global.logWithTime = function() {
  info(logSymbols.info + ' [' + moment().format('YY.MM.DD HH:mm:ss') + '] ' + [].slice.call(arguments).join(' '));
}
