expo / expo/spawn-async

Buffer output support

Open
#20 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
72
Forks
7
Avg merge
15h 36m
Merged PRs (30d)
2

Description

Hi!

First, thanks for sharing this library. I'm opening this to discuss whether and how `spawnAsync` could support exposing the raw binary stdout content.

My use case is the following: I am using [pandoc] to convert HTML content to a binary format (`.docx` in my case). Pandoc outputs the raw docx content to stdout, but since `spawnAsync` concatenates the output in a string, the binary content is scrambled which makes the docx corrupted (probably because concatenating the binary output to a string force-converts to utf8).

For this reason I couldn't use `spawnAsync` and had to use the built-in `spawn` function and basically reimplement error handling and reading from the process `stdout` stream.

Of course we don't want this change to break backwards compatibility, so `SpawnResult.stdout` should still contain a string.

What I'd imagine is a new attribute on `SpawnResult` containing the raw `Buffer[]` content, e.g.:

```ts
process = spawnAsync('pandoc', ['--from=html', '--to=docx']);
process.child.stdin.end("

Hello, world

");
result = await process;
const docxContent = Buffer.concat(result.raw); // <--
```

I'd be happy to work on this, if this sounds like a reasonable feature to add!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.