fix(server) distribute: simplify colors

This commit is contained in:
coderaiser 2021-01-11 13:44:31 +02:00
parent 0ec17645b6
commit 82c576c850
4 changed files with 5 additions and 14 deletions

View file

@ -17,8 +17,6 @@ const {
disconnectedStr,
tokenRejectedStr,
authTryStr,
makeColor,
stringToRGB,
getMessage,
getDescription,
logWraped,
@ -36,13 +34,6 @@ const wrapApply = (f, disconnect) => (status) => () => f(null, {
const closeIfNot = wraptile((socket, is) => !is && socket.close());
const addUrl = currify((url, a) => `${url}: ${a}`);
const getColorUrl = (url, name) => {
if (!name)
return url;
return makeColor(url, stringToRGB(name));
};
const rmListeners = wraptile((socket, listeners) => {
socket.removeListener('connect', listeners.onConnect);
socket.removeListener('config', listeners.onConfig);
@ -99,7 +90,7 @@ module.exports = (config, options, fn) => {
});
const superFn = wrapApply(fn, socket.close.bind(socket));
const colorUrl = getColorUrl(importUrl, name);
const colorUrl = importUrl;
const close = closeIfNot(socket, importListen);
const statusStore = fullstore();

View file

@ -6,9 +6,9 @@ const chalk = require('chalk');
const datetime = require('../../common/datetime');
const log = (isLog, name, msg) => isLog && console.log(`${datetime()} -> ${name}: ${msg}`);
const makeColor = (a, color) => chalk.rgb(color || stringToRGB(a))(a);
const makeColor = (a) => chalk.blue(a);
const getMessage = (e) => e.message || e;
const getDescription = (e) => `${e.type}: ${e.description}`;
const getDescription = (e) => e.message;
module.exports = log;
module.exports.logWraped = wraptile(log);

View file

@ -1,6 +1,6 @@
'use strict';
const {readFile} = require('fs').promises;
const {readFile} = require('fs/promises');
const {join} = require('path');
const {callbackify} = require('util');

View file

@ -1,7 +1,7 @@
'use strict';
const {homedir} = require('os');
const {readFile} = require('fs').promises;
const {readFile} = require('fs/promises');
const {join} = require('path');