Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Allow for specifying that a Command should be run in a shell (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored Nov 10, 2023
1 parent 9f94675 commit 8a4b1c1
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 61 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-pillows-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect/platform-node": patch
"@effect/platform": patch
---

allow for specifying that a Command should be run in a shell
2 changes: 1 addition & 1 deletion docs/platform-bun/Sink.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Added in v1.0.0

```ts
export declare const fromWritable: <E, A = string | Uint8Array>(
evaluate: LazyArg<Writable<any> | NodeJS.WritableStream>,
evaluate: LazyArg<Writable | NodeJS.WritableStream>,
onError: (error: unknown) => E,
options?: FromWritableOptions | undefined
) => Sink<never, E, A, never, void>
Expand Down
6 changes: 3 additions & 3 deletions docs/platform-bun/Stream.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Added in v1.0.0
```ts
export declare const fromReadable: <E, A = Uint8Array>(
evaluate: LazyArg<Readable<any> | NodeJS.ReadableStream>,
evaluate: LazyArg<Readable | NodeJS.ReadableStream>,
onError: (error: unknown) => E,
{ chunkSize }?: FromReadableOptions | undefined
) => Stream<never, E, A>
Expand All @@ -102,7 +102,7 @@ Added in v1.0.0
```ts
export declare const toString: <E>(
readable: LazyArg<Readable<any> | NodeJS.ReadableStream>,
readable: LazyArg<Readable | NodeJS.ReadableStream>,
options: {
readonly onFailure: (error: unknown) => E
readonly encoding?: BufferEncoding | undefined
Expand All @@ -119,7 +119,7 @@ Added in v1.0.0
```ts
export declare const toUint8Array: <E>(
readable: LazyArg<Readable<any> | NodeJS.ReadableStream>,
readable: LazyArg<Readable | NodeJS.ReadableStream>,
options: { readonly onFailure: (error: unknown) => E; readonly maxBytes?: SizeInput | undefined }
) => Effect<never, E, Uint8Array>
```
Expand Down
14 changes: 14 additions & 0 deletions docs/platform-node/Command.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Added in v1.0.0
- [feed](#feed)
- [flatten](#flatten)
- [pipeTo](#pipeto)
- [runInShell](#runinshell)
- [stderr](#stderr)
- [stdin](#stdin)
- [stdout](#stdout)
Expand Down Expand Up @@ -86,6 +87,19 @@ export declare const pipeTo: { (into: Command): (self: Command) => Command; (sel
Added in v1.0.0
## runInShell
**Signature**
```ts
export declare const runInShell: {
(shell: string | boolean): (self: Command) => Command
(self: Command, shell: string | boolean): Command
}
```
Added in v1.0.0
## stderr
**Signature**
Expand Down
18 changes: 18 additions & 0 deletions docs/platform/Command.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Added in v1.0.0
- [feed](#feed)
- [flatten](#flatten)
- [pipeTo](#pipeto)
- [runInShell](#runinshell)
- [stderr](#stderr)
- [stdin](#stdin)
- [stdout](#stdout)
Expand Down Expand Up @@ -111,6 +112,22 @@ export declare const pipeTo: { (into: Command): (self: Command) => Command; (sel
Added in v1.0.0
## runInShell
Allows for specifying whether or not a `Command` should be run inside a
shell.
**Signature**
```ts
export declare const runInShell: {
(shell: string | boolean): (self: Command) => Command
(self: Command, shell: string | boolean): Command
}
```
Added in v1.0.0
## stderr
Specify the standard error stream for a command.
Expand Down Expand Up @@ -338,6 +355,7 @@ export interface StandardCommand extends Command.Proto, Pipeable {
readonly args: ReadonlyArray<string>
readonly env: HashMap<string, string>
readonly cwd: Option<string>
readonly shell: boolean | string
readonly stdin: Option<Command.Input>
readonly stdout: Command.Output
readonly stderr: Command.Output
Expand Down
5 changes: 5 additions & 0 deletions packages/platform-node/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export {
* @category combinators
*/
pipeTo,
/**
* @since 1.0.0
* @category combinators
*/
runInShell,
/**
* @since 1.0.0
* @category execution
Expand Down
1 change: 1 addition & 0 deletions packages/platform-node/src/internal/commandExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const runCommand =
outputToStdioOption(command.stderr)
],
cwd: Option.getOrElse(command.cwd, constUndefined),
shell: command.shell,
env: { ...env, ...Object.fromEntries(command.env) }
})
let exited = false
Expand Down
Loading

0 comments on commit 8a4b1c1

Please sign in to comment.