@steve02081504/virtual-console 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.mjs +4 -8
  2. package/package.json +1 -1
package/main.mjs CHANGED
@@ -1,9 +1,11 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks'
2
2
  import { Console } from 'node:console'
3
+ import process from 'node:process'
3
4
  import { Writable } from 'node:stream'
5
+
4
6
  import ansiEscapes from 'ansi-escapes'
5
- import supportsAnsi from 'supports-ansi'
6
7
  import { FullProxy } from 'full-proxy'
8
+ import supportsAnsi from 'supports-ansi'
7
9
 
8
10
  export const consoleAsyncStorage = new AsyncLocalStorage()
9
11
  const cleanupRegistry = new FinalizationRegistry(cleanupToken => {
@@ -71,12 +73,12 @@ export class VirtualConsole extends Console {
71
73
  ...options,
72
74
  }
73
75
  this.freshLine = this.freshLine.bind(this)
74
- this.error = this.error.bind(this)
75
76
  this.clear = this.clear.bind(this)
76
77
  for (const method of ['log', 'info', 'warn', 'debug', 'error']) {
77
78
  if (!this[method]) continue
78
79
  const originalMethod = this[method]
79
80
  this[method] = (...args) => {
81
+ if (method == 'error' && this.options.error_handler && args.length === 1 && args[0] instanceof Error) return this.options.error_handler(args[0])
80
82
  if (!this.options.realConsoleOutput || this.options.recordOutput) return originalMethod.apply(this, args)
81
83
  this.#loggedFreshLineId = null
82
84
  return this.#base_console[method](...args)
@@ -149,12 +151,6 @@ export class VirtualConsole extends Console {
149
151
  this.#loggedFreshLineId = id
150
152
  }
151
153
 
152
- error(...args) {
153
- if (this.options.error_handler && args.length === 1 && args[0] instanceof Error)
154
- return this.options.error_handler(args[0])
155
- super.error(...args)
156
- }
157
-
158
154
  clear() {
159
155
  this.#loggedFreshLineId = null
160
156
  this.outputs = ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve02081504/virtual-console",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A virtual console for capturing and manipulating terminal output.",
5
5
  "main": "main.mjs",
6
6
  "type": "module",