Skip to content

Commit

Permalink
chore: Update platform README with example for streaming stdout (#2870)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored May 28, 2024
1 parent c12d7ff commit 2b90350
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,25 @@ NodeRuntime.runMain(
)
```

## Running a Platform Command with stdout Streamed to process.stdout

To run a command (for example `cat`) and stream its `stdout` to `process.stdout` follow these steps:

```ts
import { Command } from "@effect/platform"
import { NodeContext, NodeRuntime } from "@effect/platform-node"
import { Effect } from "effect"

// Create a command to run `cat` on a file and inherit stdout
const program = Command.make("cat", "./some-file.txt").pipe(
Command.stdout("inherit"),
Command.exitCode
)

// Run the command using NodeRuntime with the NodeContext layer
NodeRuntime.runMain(program.pipe(Effect.provide(NodeContext.layer)))
```

# FileSystem

The `@effect/platform/FileSystem` module provides a single `FileSystem` tag, which acts as the gateway for interacting with the filesystem.
Expand Down

0 comments on commit 2b90350

Please sign in to comment.