core: remove constants.js

This commit is contained in:
Micooz 2017-08-15 23:04:45 +08:00
parent 2e0fc5b77b
commit 5643ae60e9
2 changed files with 0 additions and 45 deletions

@ -1,19 +0,0 @@
import path from 'path';
beforeEach(function () {
process.env.RUN_AS = 'client';
});
describe('require', function () {
it('should not throw any errors when require the module', function () {
expect(() => require('../constants')).not.toThrow();
});
it('LOG_FILE_PATH should be blinksocks-client.log when RUN_AS is set to client', function () {
delete require.cache[require.resolve('../constants')];
const logPath = require('../constants').LOG_FILE_PATH;
expect(path.basename(logPath)).toBe('blinksocks-client.log');
});
});

@ -1,26 +0,0 @@
import os from 'os';
import path from 'path';
// paths
const HOME_DIR = os.homedir();
const BLINKSOCKS_DIR = path.join(HOME_DIR, '.blinksocks');
// log
const LOG_DIR = path.join(BLINKSOCKS_DIR, 'logs');
const LOG_FILE_PATH = path.join(LOG_DIR,
(typeof process.env.RUN_AS === 'undefined') ? 'blinksocks.log' : {
'server': 'blinksocks-server.log',
'client': 'blinksocks-client.log'
}[process.env.RUN_AS]
);
const LOG_FILE_MAX_SIZE = 2 * 1024 * 1024; // 2MB
const DEFAULT_LOG_LEVEL = 'info';
module.exports = {
HOME_DIR,
BLINKSOCKS_DIR,
LOG_DIR,
LOG_FILE_PATH,
LOG_FILE_MAX_SIZE,
DEFAULT_LOG_LEVEL
};