core: remove constants.js
This commit is contained in:
parent
2e0fc5b77b
commit
5643ae60e9
@ -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
|
||||
};
|
Loading…
Reference in New Issue
Block a user