D
Deno

help

Migrating `Deno.run` to `Deno.command` with `readlines`

Eededdneddy91888/13/2023
I had the following:
browserProcess = Deno.run({
cmd: buildArgs, // eg chrome exe path, then options
stderr: "piped",
stdout: "piped",
});
for await (const line of readLines(browserProcess.stderr!)) {
browserProcess = Deno.run({
cmd: buildArgs, // eg chrome exe path, then options
stderr: "piped",
stdout: "piped",
});
for await (const line of readLines(browserProcess.stderr!)) {
Now i'm wondering what the best way to do this with Deno.command is?
CcrowlKats8/13/2023
child.readable.pipeThrough(new TextLineStream()) child being command.spawn() and TextLineStream from https://deno.land/std@0.198.0/streams/mod.ts?s=TextLineStream
Eededdneddy91888/13/2023
🙏 thanks 🙂 been like 2+ years since ive touched deno so a lot has changed and not familiar with it all
CcrowlKats8/13/2023
not that long, right 🤔 its been a while, but cant be 2 years
Eededdneddy91888/13/2023
i dont think i touched deno/drashland shortly after my new job which was 2 years and one month ago so oculd be 1y 10m, though maybe i stopped later than i thought good to see your face though 😛
CcrowlKats8/13/2023
yea same! I saw you every now and then in destiny's channel talking with Okku, but its been a while since that as well
Eededdneddy91888/13/2023
was excited to see where destiny went, but wanna get back into deno again although: error: TS2339 [ERROR]: Property 'readable' does not exist on type 'ChildProcess'., deno v1.36.1, windows
CcrowlKats8/13/2023
ah whoops stdout
Eededdneddy91888/14/2023
still
Argument of type 'TextLineStream' is not assignable to parameter of type '{ writable: WritableStream<Uint8Array>; readable: ReadableStream<string>; }'.
Types of property 'writable' are incompatible.
Type 'WritableStream<string>' is not assignable to type 'WritableStream<Uint8Array>'.
Type 'string' is not assignable to type 'Uint8Array'.deno-ts(2345)
Argument of type 'TextLineStream' is not assignable to parameter of type '{ writable: WritableStream<Uint8Array>; readable: ReadableStream<string>; }'.
Types of property 'writable' are incompatible.
Type 'WritableStream<string>' is not assignable to type 'WritableStream<Uint8Array>'.
Type 'string' is not assignable to type 'Uint8Array'.deno-ts(2345)
:/
CcrowlKats8/14/2023
Ah, first you have to pipe through a TextDecoderStream (built-in)
Eededdneddy91888/14/2023
gotcha
CcrowlKats8/14/2023
And then through the line stream
Eededdneddy91888/14/2023
confused, where am i using TextLineStream?
const a = browserProcess.stdout.pipeThrough(new TextDecoderStream)
const b = browserProcess.stdout.pipeThrough(a);
const a = browserProcess.stdout.pipeThrough(new TextDecoderStream)
const b = browserProcess.stdout.pipeThrough(a);
oh it hink i see
CcrowlKats8/14/2023
browserProcess.stdout.pipeThrough(new TextDecoderStream()).pipeThrough(new TextLineStream())
Eededdneddy91888/14/2023
Thanks 🙏 dont suppose you'd know the ChildProcess equivelent of
this.#browser_process.stderr!.close();
this.#browser_process.stdout!.close();
this.#browser_process.close();
this.#browser_process.stderr!.close();
this.#browser_process.stdout!.close();
this.#browser_process.close();
? Tried the ai helper and got:
const stdoutReader = readerFromStreamReader(this.#browser_process.stdout.getReader())
await readAll(stdoutReader)
console.log(1)
const stderrReader = readerFromStreamReader(this.#browser_process.stderr.getReader())
await readAll(stderrReader)
this.#browser_process.kill("SIGINT")
const stdoutReader = readerFromStreamReader(this.#browser_process.stdout.getReader())
await readAll(stdoutReader)
console.log(1)
const stderrReader = readerFromStreamReader(this.#browser_process.stderr.getReader())
await readAll(stderrReader)
this.#browser_process.kill("SIGINT")
but it hangs on line 2 nvm got it sorted
Wwobsoriano9/9/2023
Hey @ededdneddy9188, do you have an example of your conversion of this? I tried this but it exits immediately https://discord.com/channels/684898665143206084/1131635673217118248/1149868174678958110

Looking for more? Join the community!

Recommended Posts
Error: Not implemented: crypto.KeyObject.prototype.asymmetricKeyTypeHello. Im trying to create a RSA Keypair, using the node **crypto.generateKeyPair** function, but i `Uncaught TypeError: encode is not a function` when using npm module `@kubernetes-client/node`I'm trying to use a particular call in the npm module `@kubernetes/client-node` from deno, but I'm gLinking to external codeif i want to link to external code, do i have to import it from https://deno.land?Impossible to install Deno on Linux Ubuntu LTS (22.04) x86_64Hello Context & Tech : Trying to install Deno on Linux Ubuntu LTS v22.04 on x86_64 architecture PrGet length of video (stream. m3u8)In deno/typescript, how can i get the length of a specific video stream (m3u8)?github account blocked errori changed email my old account to another account and when i login to deno deploy with that account npm:axios not returning anythingI'm trying to troubleshoot a problem with axios (the same snippet works fine on node). I'm callingextension method returning undefined for `text/plain`Given the following: ```ts console.log( "text/plain", extension("text/plain"), extensioServing multiple static files to an HTTP requestIf a client sends a request for an array of static files names like so. ```["component01.js", "compoKv encodes integer as doubleAnyone know why Deno.kv encodes an integer in a mutli-part key as a double? ``` const key = ["int",Looking for caching API ResponsesHello there, I'm looking for a package/or examples to cache API responses for a fresh project whicUsing ZeroMQ from NPMAnyone got fixed the same error as this issue? https://github.com/denoland/deno/issues/18345Trying to pass parameters to runtime from rustHi, I'm launching a deno runtime from my project's code. I'm trying to pass some dynamic json variconsole.log in a worker - capture or hide output?Running under `deno repl` with no permissions, this prints 'yee'. In a browser's dev tools it would Deno debugging configuration is missing?```json "deno.enable": true, "deno.unstable": true, "deno.enablePaths": ["./api"], "deno.docIs there a way to show permissions used on start up during runtime?For example: If I was to run an App with `permissions: --allow-net=${hostname}:${port}` is there a wrestrict path applied for import mapshi, is it possible to restrict importmap application to only specific path? the rationale is: - vscoBest way to pass backend data to SSR rendered view?Looking for the "proper" way to pass data to an SSR rendered view. My first idea is setting custom pImport mapHi I have this in deno.json: ``` "imports": { "./app.controller": "./app.controller.ts", ``` butWhat should I specify to pass a "char *" in Deno.dlopen?For example, this is how you would use it in Python: ```python import ctypes lib = ctypes.cdll.Load