diff --git a/mod.test.ts b/mod.test.ts index 2bde4f6..2df19e4 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -152,6 +152,22 @@ Deno.test("should error setting stdout after getting combined output", () => { } }); +Deno.test("should get output as bytes", async () => { + { + const output = await $`echo 5 && deno eval 'console.error(1);'`.bytes(); + assertEquals(new TextDecoder().decode(output), "5\n"); + } + { + const output = await $`echo 5 && deno eval 'console.error(1);'`.bytes("combined"); + assertEquals(new TextDecoder().decode(output), "5\n1\n"); + } + { + const output = await $`echo 5 && deno eval 'console.error(1);'`.env("NOCOLOR", "1") + .bytes("stderr"); + assertEquals(new TextDecoder().decode(output), "1\n"); + } +}); + Deno.test("should throw when exit code is non-zero", async () => { await assertRejects( async () => { diff --git a/mod.ts b/mod.ts index baaaa4f..51b9e10 100644 --- a/mod.ts +++ b/mod.ts @@ -47,7 +47,6 @@ export { FsFileWrapper, Path } from "./src/path.ts"; /** @deprecated Import `Path` instead. */ const PathRef = Path; // bug in deno: https://github.com/denoland/deno_lint/pull/1262 -// deno-lint-ignore verbatim-module-syntax export { PathRef }; export { CommandBuilder, diff --git a/src/command.ts b/src/command.ts index 7b2314e..4466d4d 100644 --- a/src/command.ts +++ b/src/command.ts @@ -549,7 +549,7 @@ export class CommandBuilder implements PromiseLike { * const data = (await $`command`.quiet("stdout")).stdoutBytes; * ``` */ - async bytes(kind: StreamKind): Promise { + async bytes(kind: StreamKind = "stdout"): Promise { const command = kind === "combined" ? this.quiet(kind).captureCombined() : this.quiet(kind); return (await command)[`${kind}Bytes`]; } diff --git a/src/console/logger.ts b/src/console/logger.ts index 626c4c5..2def473 100644 --- a/src/console/logger.ts +++ b/src/console/logger.ts @@ -49,5 +49,4 @@ const logger = { logAboveStaticText, }; -// deno-lint-ignore verbatim-module-syntax -- Bug https://github.com/denoland/deno_lint/pull/1262 export { logger };