From 1b53941f1c2d5f710313f8782bc5e77283cca170 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:33:55 -0300 Subject: [PATCH] perf: use Buffer to display logs --- src/services/write.ts | 10 ++++++++-- test/e2e/each-api-order.test.ts | 4 ++-- test/e2e/failure.test.ts | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/services/write.ts b/src/services/write.ts index 4ce9f8a5..c7444fc2 100644 --- a/src/services/write.ts +++ b/src/services/write.ts @@ -1,9 +1,15 @@ import type { Formatter } from '../services/format.js'; import { stdout } from 'node:process'; +import { Buffer } from 'node:buffer'; export const Write = { - log: (data: string | Uint8Array | Formatter) => - stdout.write(`${String(data)}\n`), + log: (data: string | Buffer | Uint8Array | Formatter) => { + const buffer = Buffer.isBuffer(data) + ? data + : Buffer.from(`${String(data)}\n`); + + stdout.write(buffer); + }, hr: () => { const line = '─'.repeat(stdout.columns - 10 || 40); diff --git a/test/e2e/each-api-order.test.ts b/test/e2e/each-api-order.test.ts index 4d6b1d38..91ec5152 100644 --- a/test/e2e/each-api-order.test.ts +++ b/test/e2e/each-api-order.test.ts @@ -1,11 +1,11 @@ -import { getRuntime } from '../../src/parsers/get-runtime.js'; +import { getRuntime, nodeVersion } from '../../src/parsers/get-runtime.js'; import { describe } from '../../src/modules/helpers/describe.js'; import { it } from '../../src/modules/helpers/it/core.js'; import { assert } from '../../src/modules/essentials/assert.js'; import { ext, inspectPoku } from '../__utils__/capture-cli.test.js'; import { skip } from '../../src/modules/helpers/skip.js'; -if (getRuntime() === 'deno') skip(); +if (getRuntime() === 'deno' || (nodeVersion && nodeVersion < 12)) skip(); const runtime = getRuntime(); const offset = runtime === 'bun' ? 37 : 33; diff --git a/test/e2e/failure.test.ts b/test/e2e/failure.test.ts index 3b29bfd2..b94db369 100644 --- a/test/e2e/failure.test.ts +++ b/test/e2e/failure.test.ts @@ -1,11 +1,11 @@ -import { getRuntime } from '../../src/parsers/get-runtime.js'; +import { getRuntime, nodeVersion } from '../../src/parsers/get-runtime.js'; import { describe } from '../../src/modules/helpers/describe.js'; import { it } from '../../src/modules/helpers/it/core.js'; import { assert } from '../../src/modules/essentials/assert.js'; import { inspectPoku, isBuild } from '../__utils__/capture-cli.test.js'; import { skip } from '../../src/modules/helpers/skip.js'; -if (getRuntime() === 'deno') skip(); +if (getRuntime() === 'deno' || (nodeVersion && nodeVersion < 12)) skip(); describe('Failure', async () => { await it('Sequential', async () => {