common.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require('./extensions/function_extend.js');
  2. global['DEFAULT_CHARSET'] = 'utf-8';
  3. global['BASE_DIR'] = __dirname + '/../';
  4. global['ROOT_PATH'] = __dirname + '/';
  5. global['ENV_LOCAL'] = 'local';
  6. global['ENV_DEV'] = 'dev';
  7. global['ENV_FORMAL'] = 'form';
  8. global['ENV_NEW'] = 'new';
  9. let fileName = __filename;
  10. let env = ENV_DEV;
  11. if (fileName.indexOf('/data/webapps/') === 0) {
  12. if (fileName.indexOf('/test.') !== -1 || fileName.indexOf('/test-') !== -1 || fileName.indexOf('_test/') !== -1) {
  13. global['CONF_PATH'] = '/data/webapps/conf_v2/test/';
  14. global['FRAMEWORK_PATH'] = '/data/webapps/framework/nodebase2_test/';
  15. env = ENV_DEV;
  16. } else if (fileName.indexOf('/new.') !== -1 || fileName.indexOf('/new-') !== -1 || fileName.indexOf('_new/') !== -1) {
  17. global['CONF_PATH'] = '/data/webapps/conf_v2/new/';
  18. global['FRAMEWORK_PATH'] = '/data/webapps/framework/nodebase2_new/';
  19. env = ENV_NEW;
  20. } else {
  21. global['CONF_PATH'] = '/data/webapps/conf_v2/form/';
  22. global['FRAMEWORK_PATH'] = '/data/webapps/framework/nodebase2/';
  23. env = ENV_FORMAL;
  24. }
  25. } else if (fileName.indexOf('/data_dev/') === 0 ) {
  26. // 内网开发环境
  27. global['CONF_PATH'] = '/data/webapps/conf_v2/test/';
  28. global['FRAMEWORK_PATH'] = '/data/webapps/framework/nodebase2_test/';
  29. env = ENV_DEV;
  30. } else {
  31. // 本地环境
  32. global['CONF_PATH'] = ROOT_PATH + '/conf/conf_ns/';
  33. global['FRAMEWORK_PATH'] = ROOT_PATH + '../../framework/nodebase2/';
  34. env = ENV_DEV;
  35. }
  36. global['ENV'] = env;
  37. // 公共配置文件
  38. global['GLOBALS'] = require(`${ROOT_PATH}/conf/config.inc.js`);