add option to disable check env and fix bug failed to display single argument
This commit is contained in:
parent
51d17d40a3
commit
77fba71a8e
9
index.js
9
index.js
@ -35,17 +35,18 @@ const release = (defaultConsole) => {
|
||||
|
||||
const termlog = (options = {}) => {
|
||||
// Ensure tconsole doesn't run in production mode
|
||||
if (process && process.env.NODE_ENV && process.env.NODE_ENV !== 'development') return;
|
||||
|
||||
const defaultConsole = Object.assign(Object.create(Object.getPrototypeOf(console)), console);
|
||||
|
||||
options = {
|
||||
host: DEFAULT_HOST,
|
||||
port: DEFAULT_PORT,
|
||||
ssl: false,
|
||||
disableEnvironmentCheck: false,
|
||||
...options,
|
||||
}
|
||||
|
||||
if (!options.disableEnvironmentCheck && process && process.env.NODE_ENV && process.env.NODE_ENV !== 'development') return;
|
||||
|
||||
const defaultConsole = Object.assign(Object.create(Object.getPrototypeOf(console)), console);
|
||||
|
||||
const ws = new WebSocket(`${options.ssl ? "wss" : "ws"}://${options.host}:${options.port}`);
|
||||
|
||||
ws.onopen = () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "termlog",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "Console log to terminal",
|
||||
"type": "main",
|
||||
"scripts": {
|
||||
|
@ -28,6 +28,7 @@ const getTime = () => {
|
||||
}
|
||||
|
||||
const out = (data, color = CWhite) => {
|
||||
if (!Array.isArray(data)) data = [data];
|
||||
process.stdout.write(color);
|
||||
process.stdout.write(getTime() + " ");
|
||||
console.log.apply(console, data);
|
||||
@ -73,7 +74,6 @@ const startServer = (options) => {
|
||||
const event = JSON.parse(message);
|
||||
let { type, data } = event;
|
||||
|
||||
if (!Array.isArray(data)) data = [data];
|
||||
if (!SHOWLEVELS.includes(type)) return;
|
||||
|
||||
switch (type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user