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

Allow to configure the writer to something other than stdout #30

Open
lowlighter opened this issue Oct 30, 2024 · 5 comments
Open

Allow to configure the writer to something other than stdout #30

lowlighter opened this issue Oct 30, 2024 · 5 comments

Comments

@lowlighter
Copy link

It seems like currently it's hardcoded to stdout:

private writer = Deno.stdout.writable.getWriter();

But it'd be nice to be able to set it to stderr too

The reasoning is that for cli, it's not uncommon to depends on stdout returns when using the shell syntax (like $()), but currently this messes the output

deno --allow-run=$(deno task install-and-return-path) run mod.ts

Kind similar behavior like curl/wget uses for progress bar.
Actually it may be a better default to use stderr, but it may be a breaking change

@fuxingZhang
Copy link
Collaborator

fuxingZhang commented Oct 30, 2024

Today I'm going to release a new version to support stderr.
I'd also be more than happy to merge your pull request.

@fuxingZhang
Copy link
Collaborator

Landed on v1.5.0

output: Deno.stderr,

@fuxingZhang
Copy link
Collaborator

Initially, I was using writeAllSync, but on December 27, 2023, I discovered that writeAllSync was deprecated, and the documentation recommended using the stream API.

https://deno.land/[email protected]/streams/write_all.ts?s=writeAll

(will be removed after 1.0.0) Use WritableStream, ReadableStream.from, and pipeTo()

As a result, I released version 1.4.1 (Remove deprecated writeAllSync, Use WritableStream instead).

However, today I found that both writeAll and writeAllSync are now available again. I checked the source code and issues, and found:

denoland/std#4120
denoland/std#4128

I believe writeAll is simpler. Therefore, I changed Deno.stdout.writable.getWriter() to writeAll. Since I am currently using the promise style, so I changed to use writeAll.

Loaded on v1.5.1.

@fuxingZhang
Copy link
Collaborator

fuxingZhang commented Oct 30, 2024

I forgot to change the version in the deno.json, so I force pushed the changes again, and it's working fine now.

@lowlighter
Copy link
Author

Nice ! Thanks a lot for being so quick !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants