Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use Buffer to display logs #779

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/services/write.ts
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 8 in src/services/write.ts

View check run for this annotation

Codecov / codecov/patch

src/services/write.ts#L8

Added line #L8 was not covered by tests
: Buffer.from(`${String(data)}\n`);

stdout.write(buffer);
},
hr: () => {
const line = '─'.repeat(stdout.columns - 10 || 40);

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/each-api-order.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/failure.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
Loading