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

fix: Use sync ops when clearing the console #3533

Merged
merged 2 commits into from
Dec 21, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Fix test
  • Loading branch information
nayeemrmn committed Dec 21, 2019
commit a2c75dc61d86c4ba645a036d05c8f6f450c00693
10 changes: 5 additions & 5 deletions cli/js/console_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
customInspect,
stringifyArgs,
inspect,
write,
writeSync,
stdout
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} = Deno as any;
Expand Down Expand Up @@ -331,20 +331,20 @@ test(function consoleTestError(): void {
});

test(function consoleTestClear(): void {
const stdoutWrite = stdout.write;
const stdoutWriteSync = stdout.writeSync;
const uint8 = new TextEncoder().encode("\x1b[1;1H" + "\x1b[0J");
let buffer = new Uint8Array(0);

stdout.write = async (u8: Uint8Array): Promise<number> => {
stdout.writeSync = (u8: Uint8Array): Promise<number> => {
const tmp = new Uint8Array(buffer.length + u8.length);
tmp.set(buffer, 0);
tmp.set(u8, buffer.length);
buffer = tmp;

return await write(stdout.rid, u8);
return writeSync(stdout.rid, u8);
};
console.clear();
stdout.write = stdoutWrite;
stdout.writeSync = stdoutWriteSync;
assertEquals(buffer, uint8);
});

Expand Down