@effect/platform-node-shared 0.57.0 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/NodeChildProcessSpawner.d.ts +37 -0
- package/dist/NodeChildProcessSpawner.d.ts.map +1 -0
- package/dist/NodeChildProcessSpawner.js +567 -0
- package/dist/NodeChildProcessSpawner.js.map +1 -0
- package/dist/{dts/NodeClusterSocket.d.ts → NodeClusterSocket.d.ts} +4 -7
- package/dist/NodeClusterSocket.d.ts.map +1 -0
- package/dist/{esm/NodeClusterSocket.js → NodeClusterSocket.js} +9 -10
- package/dist/NodeClusterSocket.js.map +1 -0
- package/dist/NodeFileSystem.d.ts +8 -0
- package/dist/NodeFileSystem.d.ts.map +1 -0
- package/dist/{esm/internal/fileSystem.js → NodeFileSystem.js} +125 -96
- package/dist/NodeFileSystem.js.map +1 -0
- package/dist/NodePath.d.ts +18 -0
- package/dist/NodePath.d.ts.map +1 -0
- package/dist/NodePath.js +56 -0
- package/dist/NodePath.js.map +1 -0
- package/dist/NodeRuntime.d.ts +28 -0
- package/dist/NodeRuntime.d.ts.map +1 -0
- package/dist/{esm/internal/runtime.js → NodeRuntime.js} +8 -8
- package/dist/NodeRuntime.js.map +1 -0
- package/dist/NodeSink.d.ts +40 -0
- package/dist/NodeSink.d.ts.map +1 -0
- package/dist/NodeSink.js +50 -0
- package/dist/NodeSink.js.map +1 -0
- package/dist/{dts/NodeSocket.d.ts → NodeSocket.d.ts} +10 -10
- package/dist/NodeSocket.d.ts.map +1 -0
- package/dist/{esm/NodeSocket.js → NodeSocket.js} +51 -39
- package/dist/NodeSocket.js.map +1 -0
- package/dist/{dts/NodeSocketServer.d.ts → NodeSocketServer.d.ts} +8 -10
- package/dist/NodeSocketServer.d.ts.map +1 -0
- package/dist/NodeSocketServer.js +192 -0
- package/dist/NodeSocketServer.js.map +1 -0
- package/dist/NodeStdio.d.ts +11 -0
- package/dist/NodeStdio.d.ts.map +1 -0
- package/dist/NodeStdio.js +43 -0
- package/dist/NodeStdio.js.map +1 -0
- package/dist/NodeStream.d.ts +127 -0
- package/dist/NodeStream.d.ts.map +1 -0
- package/dist/NodeStream.js +249 -0
- package/dist/NodeStream.js.map +1 -0
- package/dist/NodeTerminal.d.ts +15 -0
- package/dist/NodeTerminal.d.ts.map +1 -0
- package/dist/{esm/internal/terminal.js → NodeTerminal.js} +28 -21
- package/dist/NodeTerminal.js.map +1 -0
- package/dist/internal/utils.d.ts +2 -0
- package/dist/internal/utils.d.ts.map +1 -0
- package/dist/{esm/internal/error.js → internal/utils.js} +4 -5
- package/dist/internal/utils.js.map +1 -0
- package/package.json +53 -124
- package/src/NodeChildProcessSpawner.ts +713 -0
- package/src/NodeClusterSocket.ts +12 -13
- package/src/NodeFileSystem.ts +632 -5
- package/src/NodePath.ts +48 -9
- package/src/NodeRuntime.ts +53 -4
- package/src/NodeSink.ts +65 -62
- package/src/NodeSocket.ts +65 -49
- package/src/NodeSocketServer.ts +108 -88
- package/src/NodeStdio.ts +49 -0
- package/src/NodeStream.ts +324 -83
- package/src/NodeTerminal.ts +100 -9
- package/src/internal/{error.ts → utils.ts} +6 -7
- package/NodeClusterSocket/package.json +0 -6
- package/NodeCommandExecutor/package.json +0 -6
- package/NodeFileSystem/ParcelWatcher/package.json +0 -6
- package/NodeFileSystem/package.json +0 -6
- package/NodeKeyValueStore/package.json +0 -6
- package/NodeMultipart/package.json +0 -6
- package/NodePath/package.json +0 -6
- package/NodeRuntime/package.json +0 -6
- package/NodeSink/package.json +0 -6
- package/NodeSocket/package.json +0 -6
- package/NodeSocketServer/package.json +0 -6
- package/NodeStream/package.json +0 -6
- package/NodeTerminal/package.json +0 -6
- package/dist/cjs/NodeClusterSocket.js +0 -50
- package/dist/cjs/NodeClusterSocket.js.map +0 -1
- package/dist/cjs/NodeCommandExecutor.js +0 -14
- package/dist/cjs/NodeCommandExecutor.js.map +0 -1
- package/dist/cjs/NodeFileSystem/ParcelWatcher.js +0 -20
- package/dist/cjs/NodeFileSystem/ParcelWatcher.js.map +0 -1
- package/dist/cjs/NodeFileSystem.js +0 -18
- package/dist/cjs/NodeFileSystem.js.map +0 -1
- package/dist/cjs/NodeKeyValueStore.js +0 -18
- package/dist/cjs/NodeKeyValueStore.js.map +0 -1
- package/dist/cjs/NodeMultipart.js +0 -24
- package/dist/cjs/NodeMultipart.js.map +0 -1
- package/dist/cjs/NodePath.js +0 -28
- package/dist/cjs/NodePath.js.map +0 -1
- package/dist/cjs/NodeRuntime.js +0 -14
- package/dist/cjs/NodeRuntime.js.map +0 -1
- package/dist/cjs/NodeSink.js +0 -50
- package/dist/cjs/NodeSink.js.map +0 -1
- package/dist/cjs/NodeSocket.js +0 -153
- package/dist/cjs/NodeSocket.js.map +0 -1
- package/dist/cjs/NodeSocketServer.js +0 -178
- package/dist/cjs/NodeSocketServer.js.map +0 -1
- package/dist/cjs/NodeStream.js +0 -76
- package/dist/cjs/NodeStream.js.map +0 -1
- package/dist/cjs/NodeTerminal.js +0 -19
- package/dist/cjs/NodeTerminal.js.map +0 -1
- package/dist/cjs/internal/commandExecutor.js +0 -153
- package/dist/cjs/internal/commandExecutor.js.map +0 -1
- package/dist/cjs/internal/error.js +0 -45
- package/dist/cjs/internal/error.js.map +0 -1
- package/dist/cjs/internal/fileSystem/parcelWatcher.js +0 -68
- package/dist/cjs/internal/fileSystem/parcelWatcher.js.map +0 -1
- package/dist/cjs/internal/fileSystem.js +0 -400
- package/dist/cjs/internal/fileSystem.js.map +0 -1
- package/dist/cjs/internal/multipart.js +0 -147
- package/dist/cjs/internal/multipart.js.map +0 -1
- package/dist/cjs/internal/path.js +0 -53
- package/dist/cjs/internal/path.js.map +0 -1
- package/dist/cjs/internal/runtime.js +0 -37
- package/dist/cjs/internal/runtime.js.map +0 -1
- package/dist/cjs/internal/sink.js +0 -28
- package/dist/cjs/internal/sink.js.map +0 -1
- package/dist/cjs/internal/stream.js +0 -233
- package/dist/cjs/internal/stream.js.map +0 -1
- package/dist/cjs/internal/terminal.js +0 -86
- package/dist/cjs/internal/terminal.js.map +0 -1
- package/dist/dts/NodeClusterSocket.d.ts.map +0 -1
- package/dist/dts/NodeCommandExecutor.d.ts +0 -12
- package/dist/dts/NodeCommandExecutor.d.ts.map +0 -1
- package/dist/dts/NodeFileSystem/ParcelWatcher.d.ts +0 -13
- package/dist/dts/NodeFileSystem/ParcelWatcher.d.ts.map +0 -1
- package/dist/dts/NodeFileSystem.d.ts +0 -11
- package/dist/dts/NodeFileSystem.d.ts.map +0 -1
- package/dist/dts/NodeKeyValueStore.d.ts +0 -12
- package/dist/dts/NodeKeyValueStore.d.ts.map +0 -1
- package/dist/dts/NodeMultipart.d.ts +0 -27
- package/dist/dts/NodeMultipart.d.ts.map +0 -1
- package/dist/dts/NodePath.d.ts +0 -21
- package/dist/dts/NodePath.d.ts.map +0 -1
- package/dist/dts/NodeRuntime.d.ts +0 -10
- package/dist/dts/NodeRuntime.d.ts.map +0 -1
- package/dist/dts/NodeSink.d.ts +0 -36
- package/dist/dts/NodeSink.d.ts.map +0 -1
- package/dist/dts/NodeSocket.d.ts.map +0 -1
- package/dist/dts/NodeSocketServer.d.ts.map +0 -1
- package/dist/dts/NodeStream.d.ts +0 -119
- package/dist/dts/NodeStream.d.ts.map +0 -1
- package/dist/dts/NodeTerminal.d.ts +0 -18
- package/dist/dts/NodeTerminal.d.ts.map +0 -1
- package/dist/dts/internal/commandExecutor.d.ts +0 -2
- package/dist/dts/internal/commandExecutor.d.ts.map +0 -1
- package/dist/dts/internal/error.d.ts +0 -2
- package/dist/dts/internal/error.d.ts.map +0 -1
- package/dist/dts/internal/fileSystem/parcelWatcher.d.ts +0 -4
- package/dist/dts/internal/fileSystem/parcelWatcher.d.ts.map +0 -1
- package/dist/dts/internal/fileSystem.d.ts +0 -2
- package/dist/dts/internal/fileSystem.d.ts.map +0 -1
- package/dist/dts/internal/multipart.d.ts +0 -2
- package/dist/dts/internal/multipart.d.ts.map +0 -1
- package/dist/dts/internal/path.d.ts +0 -2
- package/dist/dts/internal/path.d.ts.map +0 -1
- package/dist/dts/internal/runtime.d.ts +0 -2
- package/dist/dts/internal/runtime.d.ts.map +0 -1
- package/dist/dts/internal/sink.d.ts +0 -2
- package/dist/dts/internal/sink.d.ts.map +0 -1
- package/dist/dts/internal/stream.d.ts +0 -2
- package/dist/dts/internal/stream.d.ts.map +0 -1
- package/dist/dts/internal/terminal.d.ts +0 -2
- package/dist/dts/internal/terminal.d.ts.map +0 -1
- package/dist/esm/NodeClusterSocket.js.map +0 -1
- package/dist/esm/NodeCommandExecutor.js +0 -7
- package/dist/esm/NodeCommandExecutor.js.map +0 -1
- package/dist/esm/NodeFileSystem/ParcelWatcher.js +0 -12
- package/dist/esm/NodeFileSystem/ParcelWatcher.js.map +0 -1
- package/dist/esm/NodeFileSystem.js +0 -10
- package/dist/esm/NodeFileSystem.js.map +0 -1
- package/dist/esm/NodeKeyValueStore.js +0 -10
- package/dist/esm/NodeKeyValueStore.js.map +0 -1
- package/dist/esm/NodeMultipart.js +0 -17
- package/dist/esm/NodeMultipart.js.map +0 -1
- package/dist/esm/NodePath.js +0 -20
- package/dist/esm/NodePath.js.map +0 -1
- package/dist/esm/NodeRuntime.js +0 -7
- package/dist/esm/NodeRuntime.js.map +0 -1
- package/dist/esm/NodeSink.js +0 -43
- package/dist/esm/NodeSink.js.map +0 -1
- package/dist/esm/NodeSocket.js.map +0 -1
- package/dist/esm/NodeSocketServer.js +0 -167
- package/dist/esm/NodeSocketServer.js.map +0 -1
- package/dist/esm/NodeStream.js +0 -69
- package/dist/esm/NodeStream.js.map +0 -1
- package/dist/esm/NodeTerminal.js +0 -12
- package/dist/esm/NodeTerminal.js.map +0 -1
- package/dist/esm/internal/commandExecutor.js +0 -146
- package/dist/esm/internal/commandExecutor.js.map +0 -1
- package/dist/esm/internal/error.js.map +0 -1
- package/dist/esm/internal/fileSystem/parcelWatcher.js +0 -61
- package/dist/esm/internal/fileSystem/parcelWatcher.js.map +0 -1
- package/dist/esm/internal/fileSystem.js.map +0 -1
- package/dist/esm/internal/multipart.js +0 -137
- package/dist/esm/internal/multipart.js.map +0 -1
- package/dist/esm/internal/path.js +0 -46
- package/dist/esm/internal/path.js.map +0 -1
- package/dist/esm/internal/runtime.js.map +0 -1
- package/dist/esm/internal/sink.js +0 -19
- package/dist/esm/internal/sink.js.map +0 -1
- package/dist/esm/internal/stream.js +0 -217
- package/dist/esm/internal/stream.js.map +0 -1
- package/dist/esm/internal/terminal.js.map +0 -1
- package/dist/esm/package.json +0 -4
- package/src/NodeCommandExecutor.ts +0 -13
- package/src/NodeFileSystem/ParcelWatcher.ts +0 -15
- package/src/NodeKeyValueStore.ts +0 -20
- package/src/NodeMultipart.ts +0 -40
- package/src/internal/commandExecutor.ts +0 -251
- package/src/internal/fileSystem/parcelWatcher.ts +0 -64
- package/src/internal/fileSystem.ts +0 -648
- package/src/internal/multipart.ts +0 -141
- package/src/internal/path.ts +0 -63
- package/src/internal/runtime.ts +0 -34
- package/src/internal/sink.ts +0 -57
- package/src/internal/stream.ts +0 -375
- package/src/internal/terminal.ts +0 -100
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { SystemError } from "@effect/platform/Error";
|
|
2
|
-
import * as Cause from "effect/Cause";
|
|
3
|
-
import * as Channel from "effect/Channel";
|
|
4
|
-
import * as Chunk from "effect/Chunk";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Exit from "effect/Exit";
|
|
7
|
-
import * as Fiber from "effect/Fiber";
|
|
8
|
-
import { dual } from "effect/Function";
|
|
9
|
-
import * as MutableRef from "effect/MutableRef";
|
|
10
|
-
import * as Runtime from "effect/Runtime";
|
|
11
|
-
import * as Stream from "effect/Stream";
|
|
12
|
-
import { Readable } from "node:stream";
|
|
13
|
-
/** @internal */
|
|
14
|
-
export const fromReadable = (evaluate, onError, options) => Stream.fromChannel(fromReadableChannel(evaluate, onError, options));
|
|
15
|
-
/** @internal */
|
|
16
|
-
export const toString = (readable, options) => {
|
|
17
|
-
const maxBytesNumber = options.maxBytes ? Number(options.maxBytes) : undefined;
|
|
18
|
-
return Effect.acquireUseRelease(Effect.sync(() => {
|
|
19
|
-
const stream = readable();
|
|
20
|
-
stream.setEncoding(options.encoding ?? "utf8");
|
|
21
|
-
return stream;
|
|
22
|
-
}), stream => Effect.async(resume => {
|
|
23
|
-
let string = "";
|
|
24
|
-
let bytes = 0;
|
|
25
|
-
stream.once("error", err => {
|
|
26
|
-
resume(Effect.fail(options.onFailure(err)));
|
|
27
|
-
});
|
|
28
|
-
stream.once("end", () => {
|
|
29
|
-
resume(Effect.succeed(string));
|
|
30
|
-
});
|
|
31
|
-
stream.on("data", chunk => {
|
|
32
|
-
string += chunk;
|
|
33
|
-
bytes += Buffer.byteLength(chunk);
|
|
34
|
-
if (maxBytesNumber && bytes > maxBytesNumber) {
|
|
35
|
-
resume(Effect.fail(options.onFailure(new Error("maxBytes exceeded"))));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}), stream => Effect.sync(() => {
|
|
39
|
-
if ("closed" in stream && !stream.closed) {
|
|
40
|
-
stream.destroy();
|
|
41
|
-
}
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
44
|
-
/** @internal */
|
|
45
|
-
export const toUint8Array = (readable, options) => {
|
|
46
|
-
const maxBytesNumber = options.maxBytes ? Number(options.maxBytes) : undefined;
|
|
47
|
-
return Effect.acquireUseRelease(Effect.sync(readable), stream => Effect.async(resume => {
|
|
48
|
-
let buffer = Buffer.alloc(0);
|
|
49
|
-
let bytes = 0;
|
|
50
|
-
stream.once("error", err => {
|
|
51
|
-
resume(Effect.fail(options.onFailure(err)));
|
|
52
|
-
});
|
|
53
|
-
stream.once("end", () => {
|
|
54
|
-
resume(Effect.succeed(buffer));
|
|
55
|
-
});
|
|
56
|
-
stream.on("data", chunk => {
|
|
57
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
58
|
-
bytes += chunk.length;
|
|
59
|
-
if (maxBytesNumber && bytes > maxBytesNumber) {
|
|
60
|
-
resume(Effect.fail(options.onFailure(new Error("maxBytes exceeded"))));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}), stream => Effect.sync(() => {
|
|
64
|
-
if ("closed" in stream && !stream.closed) {
|
|
65
|
-
stream.destroy();
|
|
66
|
-
}
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
/** @internal */
|
|
70
|
-
export const fromDuplex = (evaluate, onError, options) => Channel.suspend(() => {
|
|
71
|
-
const duplex = evaluate();
|
|
72
|
-
if (!duplex.readable) {
|
|
73
|
-
return Channel.void;
|
|
74
|
-
}
|
|
75
|
-
const exit = MutableRef.make(undefined);
|
|
76
|
-
return Channel.embedInput(unsafeReadableRead(duplex, onError, exit, options), writeInput(duplex, cause => Effect.sync(() => MutableRef.set(exit, Exit.failCause(cause))), options));
|
|
77
|
-
});
|
|
78
|
-
/** @internal */
|
|
79
|
-
export const pipeThroughDuplex = /*#__PURE__*/dual(args => Stream.StreamTypeId in args[0], (self, duplex, onError, options) => Stream.pipeThroughChannelOrFail(self, fromDuplex(duplex, onError, options)));
|
|
80
|
-
/** @internal */
|
|
81
|
-
export const pipeThroughSimple = /*#__PURE__*/dual(2, (self, duplex) => Stream.pipeThroughChannelOrFail(self, fromDuplex(duplex, cause => new SystemError({
|
|
82
|
-
module: "Stream",
|
|
83
|
-
method: "pipeThroughSimple",
|
|
84
|
-
reason: "Unknown",
|
|
85
|
-
cause
|
|
86
|
-
}))));
|
|
87
|
-
/** @internal */
|
|
88
|
-
export const fromReadableChannel = (evaluate, onError, options) => Channel.suspend(() => unsafeReadableRead(evaluate(), onError, MutableRef.make(undefined), options));
|
|
89
|
-
/** @internal */
|
|
90
|
-
export const writeInput = (writable, onFailure, {
|
|
91
|
-
encoding,
|
|
92
|
-
endOnDone = true
|
|
93
|
-
} = {}, onDone = Effect.void) => {
|
|
94
|
-
const write = writeEffect(writable, encoding);
|
|
95
|
-
const close = endOnDone ? Effect.async(resume => {
|
|
96
|
-
if ("closed" in writable && writable.closed) {
|
|
97
|
-
resume(Effect.void);
|
|
98
|
-
} else {
|
|
99
|
-
writable.once("finish", () => resume(Effect.void));
|
|
100
|
-
writable.end();
|
|
101
|
-
}
|
|
102
|
-
}) : Effect.void;
|
|
103
|
-
return {
|
|
104
|
-
awaitRead: () => Effect.void,
|
|
105
|
-
emit: write,
|
|
106
|
-
error: cause => Effect.zipRight(close, onFailure(cause)),
|
|
107
|
-
done: _ => Effect.zipRight(close, onDone)
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
/** @internal */
|
|
111
|
-
export const writeEffect = (writable, encoding) => chunk => chunk.length === 0 ? Effect.void : Effect.async(resume => {
|
|
112
|
-
const iterator = chunk[Symbol.iterator]();
|
|
113
|
-
let next = iterator.next();
|
|
114
|
-
function loop() {
|
|
115
|
-
const item = next;
|
|
116
|
-
next = iterator.next();
|
|
117
|
-
const success = writable.write(item.value, encoding);
|
|
118
|
-
if (next.done) {
|
|
119
|
-
resume(Effect.void);
|
|
120
|
-
} else if (success) {
|
|
121
|
-
loop();
|
|
122
|
-
} else {
|
|
123
|
-
writable.once("drain", loop);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
loop();
|
|
127
|
-
});
|
|
128
|
-
const unsafeReadableRead = (readable, onError, exit, options) => {
|
|
129
|
-
if (!readable.readable) {
|
|
130
|
-
return Channel.void;
|
|
131
|
-
}
|
|
132
|
-
const latch = Effect.unsafeMakeLatch(false);
|
|
133
|
-
function onReadable() {
|
|
134
|
-
latch.unsafeOpen();
|
|
135
|
-
}
|
|
136
|
-
function onErr(err) {
|
|
137
|
-
exit.current = Exit.fail(onError(err));
|
|
138
|
-
latch.unsafeOpen();
|
|
139
|
-
}
|
|
140
|
-
function onEnd() {
|
|
141
|
-
exit.current = Exit.void;
|
|
142
|
-
latch.unsafeOpen();
|
|
143
|
-
}
|
|
144
|
-
readable.on("readable", onReadable);
|
|
145
|
-
readable.on("error", onErr);
|
|
146
|
-
readable.on("end", onEnd);
|
|
147
|
-
const chunkSize = options?.chunkSize ? Number(options.chunkSize) : undefined;
|
|
148
|
-
const read = Channel.suspend(function loop() {
|
|
149
|
-
let item = readable.read(chunkSize);
|
|
150
|
-
if (item === null) {
|
|
151
|
-
if (exit.current) {
|
|
152
|
-
return Channel.fromEffect(exit.current);
|
|
153
|
-
}
|
|
154
|
-
latch.unsafeClose();
|
|
155
|
-
return Channel.flatMap(latch.await, loop);
|
|
156
|
-
}
|
|
157
|
-
const arr = [item];
|
|
158
|
-
while (true) {
|
|
159
|
-
item = readable.read(chunkSize);
|
|
160
|
-
if (item === null) {
|
|
161
|
-
return Channel.flatMap(Channel.write(Chunk.unsafeFromArray(arr)), loop);
|
|
162
|
-
}
|
|
163
|
-
arr.push(item);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return Channel.ensuring(read, Effect.sync(() => {
|
|
167
|
-
readable.off("readable", onReadable);
|
|
168
|
-
readable.off("error", onErr);
|
|
169
|
-
readable.off("end", onEnd);
|
|
170
|
-
if (options?.closeOnDone !== false && "closed" in readable && !readable.closed) {
|
|
171
|
-
readable.destroy();
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
};
|
|
175
|
-
class StreamAdapter extends Readable {
|
|
176
|
-
readLatch;
|
|
177
|
-
fiber = undefined;
|
|
178
|
-
constructor(runtime, stream) {
|
|
179
|
-
super({});
|
|
180
|
-
this.readLatch = Effect.unsafeMakeLatch(false);
|
|
181
|
-
this.fiber = Runtime.runFork(runtime)(this.readLatch.whenOpen(Stream.runForEachChunk(stream, chunk => this.readLatch.whenOpen(Effect.sync(() => {
|
|
182
|
-
if (chunk.length === 0) return;
|
|
183
|
-
this.readLatch.unsafeClose();
|
|
184
|
-
for (const item of chunk) {
|
|
185
|
-
if (typeof item === "string") {
|
|
186
|
-
this.push(item, "utf8");
|
|
187
|
-
} else {
|
|
188
|
-
this.push(item);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
})))));
|
|
192
|
-
this.fiber.addObserver(exit => {
|
|
193
|
-
this.fiber = undefined;
|
|
194
|
-
if (Exit.isSuccess(exit)) {
|
|
195
|
-
this.push(null);
|
|
196
|
-
} else {
|
|
197
|
-
this.destroy(Cause.squash(exit.cause));
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
_read(_size) {
|
|
202
|
-
this.readLatch.unsafeOpen();
|
|
203
|
-
}
|
|
204
|
-
_destroy(error, callback) {
|
|
205
|
-
if (!this.fiber) {
|
|
206
|
-
return callback(error);
|
|
207
|
-
}
|
|
208
|
-
Effect.runFork(Fiber.interrupt(this.fiber)).addObserver(exit => {
|
|
209
|
-
callback(exit._tag === "Failure" ? Cause.squash(exit.cause) : error);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/** @internal */
|
|
214
|
-
export const toReadable = stream => Effect.map(Effect.runtime(), runtime => new StreamAdapter(runtime, stream));
|
|
215
|
-
/** @internal */
|
|
216
|
-
export const toReadableNever = stream => new StreamAdapter(Runtime.defaultRuntime, stream);
|
|
217
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","names":["SystemError","Cause","Channel","Chunk","Effect","Exit","Fiber","dual","MutableRef","Runtime","Stream","Readable","fromReadable","evaluate","onError","options","fromChannel","fromReadableChannel","toString","readable","maxBytesNumber","maxBytes","Number","undefined","acquireUseRelease","sync","stream","setEncoding","encoding","async","resume","string","bytes","once","err","fail","onFailure","succeed","on","chunk","Buffer","byteLength","Error","closed","destroy","toUint8Array","buffer","alloc","concat","length","fromDuplex","suspend","duplex","void","exit","make","embedInput","unsafeReadableRead","writeInput","cause","set","failCause","pipeThroughDuplex","args","StreamTypeId","self","pipeThroughChannelOrFail","pipeThroughSimple","module","method","reason","writable","endOnDone","onDone","write","writeEffect","close","end","awaitRead","emit","error","zipRight","done","_","iterator","Symbol","next","loop","item","success","value","latch","unsafeMakeLatch","onReadable","unsafeOpen","onErr","current","onEnd","chunkSize","read","fromEffect","unsafeClose","flatMap","await","arr","unsafeFromArray","push","ensuring","off","closeOnDone","StreamAdapter","readLatch","fiber","constructor","runtime","runFork","whenOpen","runForEachChunk","addObserver","isSuccess","squash","_read","_size","_destroy","callback","interrupt","_tag","toReadable","map","toReadableNever","defaultRuntime"],"sources":["../../../src/internal/stream.ts"],"sourcesContent":[null],"mappings":"AAAA,SAA6BA,WAAW,QAAQ,wBAAwB;AAExE,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AAEzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,SAASC,QAAQ,QAAQ,aAAa;AAGtC;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,QAAmD,EACnDC,OAA8B,EAC9BC,OAA6B,KAE7BL,MAAM,CAACM,WAAW,CAChBC,mBAAmB,CAAOJ,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC,CACtD;AAEH;AACA,OAAO,MAAMG,QAAQ,GAAGA,CACtBC,QAAmD,EACnDJ,OAIC,KAC2B;EAC5B,MAAMK,cAAc,GAAGL,OAAO,CAACM,QAAQ,GAAGC,MAAM,CAACP,OAAO,CAACM,QAAQ,CAAC,GAAGE,SAAS;EAC9E,OAAOnB,MAAM,CAACoB,iBAAiB,CAC7BpB,MAAM,CAACqB,IAAI,CAAC,MAAK;IACf,MAAMC,MAAM,GAAGP,QAAQ,EAAE;IACzBO,MAAM,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IAAI,IAAI;MAC9B,IAAI,CAAC0D,KAAK,GAAGzF,SAAS;MACtB,IAAIlB,IAAI,CAACkH,SAAS,CAACjE,IAAI,CAAC,EAAE;QACxB,IAAI,CAACoD,IAAI,CAAC,IAAI,CAAC;MACjB,CAAC,MAAM;QACL,IAAI,CAAC9D,OAAO,CAAC3C,KAAK,CAACuH,MAAM,CAAClE,IAAI,CAACK,KAAK,CAAQ,CAAC;MAC/C;IACF,CAAC,CAAC;EACJ;EAEA8D,KAAKA,CAACC,KAAa;IACjB,IAAI,CAACX,SAAS,CAACjB,UAAU,EAAE;EAC7B;EAEA6B,QAAQA,CAAC3C,KAAmB,EAAE4C,QAAoD;IAChF,IAAI,CAAC,IAAI,CAACZ,KAAK,EAAE;MACf,OAAOY,QAAQ,CAAC5C,KAAK,CAAC;IACxB;IACA5E,MAAM,CAAC+G,OAAO,CAAC7G,KAAK,CAACuH,SAAS,CAAC,IAAI,CAACb,KAAK,CAAC,CAAC,CAACM,WAAW,CAAEhE,IAAI,IAAI;MAC/DsE,QAAQ,CAACtE,IAAI,CAACwE,IAAI,KAAK,SAAS,GAAG7H,KAAK,CAACuH,MAAM,CAAClE,IAAI,CAACK,KAAK,CAAQ,GAAGqB,KAAK,CAAC;IAC7E,CAAC,CAAC;EACJ;;AAGF;AACA,OAAO,MAAM+C,UAAU,GACrBrG,MAAgD,IAEhDtB,MAAM,CAAC4H,GAAG,CACR5H,MAAM,CAAC8G,OAAO,EAAK,EAClBA,OAAO,IAAK,IAAIJ,aAAa,CAACI,OAAO,EAAExF,MAAM,CAAC,CAChD;AAEH;AACA,OAAO,MAAMuG,eAAe,GAC1BvG,MAA6C,IAChC,IAAIoF,aAAa,CAACrG,OAAO,CAACyH,cAAc,EAAExG,MAAM,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","names":["Error","Terminal","Effect","Exit","Layer","Mailbox","Option","RcRef","readline","defaultShouldQuit","input","key","ctrl","name","make","fnUntraced","shouldQuit","stdin","process","stdout","rlRef","acquire","acquireRelease","sync","rl","createInterface","escapeCodeTimeout","emitKeypressEvents","isTTY","setRawMode","close","columns","readInput","gen","get","mailbox","handleKeypress","s","k","userInput","fromNullable","meta","shift","unsafeOffer","unsafeDone","void","addFinalizer","off","on","readLine","pipe","flatMap","readlineInterface","async","resume","onLine","line","succeed","once","scoped","display","prompt","uninterruptible","write","err","fail","BadArgument","module","method","description","cause","of","layer"],"sources":["../../../src/internal/terminal.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,wBAAwB;AAC/C,OAAO,KAAKC,QAAQ,MAAM,2BAA2B;AACrD,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC,MAAMC,iBAAiB,GAAIC,KAAyB,IAClDA,KAAK,CAACC,GAAG,CAACC,IAAI,KAAKF,KAAK,CAACC,GAAG,CAACE,IAAI,KAAK,GAAG,IAAIH,KAAK,CAACC,GAAG,CAACE,IAAI,KAAK,GAAG,CAAC;AAEtE;AACA,OAAO,MAAMC,IAAI,gBAAGZ,MAAM,CAACa,UAAU,CAAC,WACpCC,UAAA,GAAqDP,iBAAiB;EAEtE,MAAMQ,KAAK,GAAGC,OAAO,CAACD,KAAK;EAC3B,MAAME,MAAM,GAAGD,OAAO,CAACC,MAAM;EAE7B;EACA,MAAMC,KAAK,GAAG,OAAOb,KAAK,CAACO,IAAI,CAAC;IAC9BO,OAAO,EAAEnB,MAAM,CAACoB,cAAc,CAC5BpB,MAAM,CAACqB,IAAI,CAAC,MAAK;MACf,MAAMC,EAAE,GAAGhB,QAAQ,CAAC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CAAC,CACH;EAEH,OAAO5C,QAAQ,CAACA,QAAQ,CAACsE,EAAE,CAAC;IAC1BxC,OAAO;IACPC,SAAS;IACTiB,QAAQ;IACRW;GACD,CAAC;AACJ,CAAC,CAAC;AAEF;AACA,OAAO,MAAMY,KAAK,gBAAmCpE,KAAK,CAACuD,MAAM,CAAC1D,QAAQ,CAACA,QAAQ,eAAEa,IAAI,CAACL,iBAAiB,CAAC,CAAC","ignoreList":[]}
|
package/dist/esm/package.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 1.0.0
|
|
3
|
-
*/
|
|
4
|
-
import type { CommandExecutor } from "@effect/platform/CommandExecutor"
|
|
5
|
-
import type { FileSystem } from "@effect/platform/FileSystem"
|
|
6
|
-
import type { Layer } from "effect/Layer"
|
|
7
|
-
import * as internal from "./internal/commandExecutor.js"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @since 1.0.0
|
|
11
|
-
* @category layer
|
|
12
|
-
*/
|
|
13
|
-
export const layer: Layer<CommandExecutor, never, FileSystem> = internal.layer
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 1.0.0
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { WatchBackend } from "@effect/platform/FileSystem"
|
|
6
|
-
import type { Layer } from "effect/Layer"
|
|
7
|
-
import * as internal from "../internal/fileSystem/parcelWatcher.js"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* You can provide this Layer to use `@parcel/watcher` as the backend for watching files.
|
|
11
|
-
*
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
* @category layer
|
|
14
|
-
*/
|
|
15
|
-
export const layer: Layer<WatchBackend> = internal.layer
|
package/src/NodeKeyValueStore.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 1.0.0
|
|
3
|
-
*/
|
|
4
|
-
import type * as PlatformError from "@effect/platform/Error"
|
|
5
|
-
import * as KeyValueStore from "@effect/platform/KeyValueStore"
|
|
6
|
-
import * as Layer from "effect/Layer"
|
|
7
|
-
import * as FileSystem from "./NodeFileSystem.js"
|
|
8
|
-
import * as Path from "./NodePath.js"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @since 1.0.0
|
|
12
|
-
* @category layers
|
|
13
|
-
*/
|
|
14
|
-
export const layerFileSystem: (
|
|
15
|
-
directory: string
|
|
16
|
-
) => Layer.Layer<KeyValueStore.KeyValueStore, PlatformError.PlatformError> = (directory: string) =>
|
|
17
|
-
Layer.provide(
|
|
18
|
-
KeyValueStore.layerFileSystem(directory),
|
|
19
|
-
Layer.merge(FileSystem.layer, Path.layer)
|
|
20
|
-
)
|
package/src/NodeMultipart.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 1.0.0
|
|
3
|
-
*/
|
|
4
|
-
import type * as FileSystem from "@effect/platform/FileSystem"
|
|
5
|
-
import type * as Multipart from "@effect/platform/Multipart"
|
|
6
|
-
import type * as Path from "@effect/platform/Path"
|
|
7
|
-
import type * as Effect from "effect/Effect"
|
|
8
|
-
import type * as Scope from "effect/Scope"
|
|
9
|
-
import type * as Stream from "effect/Stream"
|
|
10
|
-
import type { IncomingHttpHeaders } from "node:http"
|
|
11
|
-
import type { Readable } from "node:stream"
|
|
12
|
-
import * as internal from "./internal/multipart.js"
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @since 1.0.0
|
|
16
|
-
* @category constructors
|
|
17
|
-
*/
|
|
18
|
-
export const stream: (
|
|
19
|
-
source: Readable,
|
|
20
|
-
headers: IncomingHttpHeaders
|
|
21
|
-
) => Stream.Stream<Multipart.Part, Multipart.MultipartError> = internal.stream
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @since 1.0.0
|
|
25
|
-
* @category constructors
|
|
26
|
-
*/
|
|
27
|
-
export const persisted: (
|
|
28
|
-
source: Readable,
|
|
29
|
-
headers: IncomingHttpHeaders
|
|
30
|
-
) => Effect.Effect<
|
|
31
|
-
Multipart.Persisted,
|
|
32
|
-
Multipart.MultipartError,
|
|
33
|
-
FileSystem.FileSystem | Path.Path | Scope.Scope
|
|
34
|
-
> = internal.persisted
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
* @category conversions
|
|
39
|
-
*/
|
|
40
|
-
export const fileToReadable: (file: Multipart.File) => Readable = internal.fileToReadable
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import * as Command from "@effect/platform/Command"
|
|
2
|
-
import * as CommandExecutor from "@effect/platform/CommandExecutor"
|
|
3
|
-
import type * as Error from "@effect/platform/Error"
|
|
4
|
-
import * as FileSystem from "@effect/platform/FileSystem"
|
|
5
|
-
import * as Deferred from "effect/Deferred"
|
|
6
|
-
import * as Effect from "effect/Effect"
|
|
7
|
-
import { constUndefined, identity, pipe } from "effect/Function"
|
|
8
|
-
import * as Inspectable from "effect/Inspectable"
|
|
9
|
-
import * as Layer from "effect/Layer"
|
|
10
|
-
import * as Option from "effect/Option"
|
|
11
|
-
import type * as Scope from "effect/Scope"
|
|
12
|
-
import * as Sink from "effect/Sink"
|
|
13
|
-
import * as Stream from "effect/Stream"
|
|
14
|
-
import * as ChildProcess from "node:child_process"
|
|
15
|
-
import { handleErrnoException } from "./error.js"
|
|
16
|
-
import { fromWritable } from "./sink.js"
|
|
17
|
-
import { fromReadable } from "./stream.js"
|
|
18
|
-
|
|
19
|
-
const inputToStdioOption = (stdin: Command.Command.Input): "pipe" | "inherit" =>
|
|
20
|
-
typeof stdin === "string" ? stdin : "pipe"
|
|
21
|
-
|
|
22
|
-
const outputToStdioOption = (output: Command.Command.Output): "pipe" | "inherit" =>
|
|
23
|
-
typeof output === "string" ? output : "pipe"
|
|
24
|
-
|
|
25
|
-
const toError = (err: unknown): Error => err instanceof globalThis.Error ? err : new globalThis.Error(String(err))
|
|
26
|
-
|
|
27
|
-
const toPlatformError = (
|
|
28
|
-
method: string,
|
|
29
|
-
error: NodeJS.ErrnoException,
|
|
30
|
-
command: Command.Command
|
|
31
|
-
): Error.PlatformError => {
|
|
32
|
-
const flattened = Command.flatten(command).reduce((acc, curr) => {
|
|
33
|
-
const command = `${curr.command} ${curr.args.join(" ")}`
|
|
34
|
-
return acc.length === 0 ? command : `${acc} | ${command}`
|
|
35
|
-
}, "")
|
|
36
|
-
return handleErrnoException("Command", method)(error, [flattened])
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type ExitCode = readonly [code: number | null, signal: NodeJS.Signals | null]
|
|
40
|
-
type ExitCodeDeferred = Deferred.Deferred<ExitCode>
|
|
41
|
-
|
|
42
|
-
const ProcessProto = {
|
|
43
|
-
[CommandExecutor.ProcessTypeId]: CommandExecutor.ProcessTypeId,
|
|
44
|
-
...Inspectable.BaseProto,
|
|
45
|
-
toJSON(this: CommandExecutor.Process) {
|
|
46
|
-
return {
|
|
47
|
-
_id: "@effect/platform/CommandExecutor/Process",
|
|
48
|
-
pid: this.pid
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const runCommand =
|
|
54
|
-
(fileSystem: FileSystem.FileSystem) =>
|
|
55
|
-
(command: Command.Command): Effect.Effect<CommandExecutor.Process, Error.PlatformError, Scope.Scope> => {
|
|
56
|
-
switch (command._tag) {
|
|
57
|
-
case "StandardCommand": {
|
|
58
|
-
const spawn = Effect.flatMap(
|
|
59
|
-
Deferred.make<ExitCode>(),
|
|
60
|
-
(exitCode) =>
|
|
61
|
-
Effect.async<readonly [ChildProcess.ChildProcess, ExitCodeDeferred], Error.PlatformError>(
|
|
62
|
-
(resume) => {
|
|
63
|
-
const handle = ChildProcess.spawn(command.command, command.args, {
|
|
64
|
-
stdio: [
|
|
65
|
-
inputToStdioOption(command.stdin),
|
|
66
|
-
outputToStdioOption(command.stdout),
|
|
67
|
-
outputToStdioOption(command.stderr)
|
|
68
|
-
],
|
|
69
|
-
cwd: Option.getOrElse(command.cwd, constUndefined),
|
|
70
|
-
shell: command.shell,
|
|
71
|
-
env: { ...process.env, ...Object.fromEntries(command.env) },
|
|
72
|
-
detached: process.platform !== "win32"
|
|
73
|
-
})
|
|
74
|
-
handle.on("error", (err) => {
|
|
75
|
-
resume(Effect.fail(toPlatformError("spawn", err, command)))
|
|
76
|
-
})
|
|
77
|
-
handle.on("exit", (...args) => {
|
|
78
|
-
Deferred.unsafeDone(exitCode, Effect.succeed(args))
|
|
79
|
-
})
|
|
80
|
-
handle.on("spawn", () => {
|
|
81
|
-
resume(Effect.succeed([handle, exitCode]))
|
|
82
|
-
})
|
|
83
|
-
return Effect.sync(() => {
|
|
84
|
-
handle.kill("SIGTERM")
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
const killProcessGroup = process.platform === "win32" ?
|
|
91
|
-
(handle: ChildProcess.ChildProcess, _: NodeJS.Signals) =>
|
|
92
|
-
Effect.async<void, Error.PlatformError>((resume) => {
|
|
93
|
-
ChildProcess.exec(`taskkill /pid ${handle.pid} /T /F`, (error) => {
|
|
94
|
-
if (error) {
|
|
95
|
-
resume(Effect.fail(toPlatformError("kill", toError(error), command)))
|
|
96
|
-
} else {
|
|
97
|
-
resume(Effect.void)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
: (handle: ChildProcess.ChildProcess, signal: NodeJS.Signals) =>
|
|
102
|
-
Effect.try({
|
|
103
|
-
try: () => process.kill(-handle.pid!, signal),
|
|
104
|
-
catch: (error) => toPlatformError("kill", toError(error), command)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const killProcess = (handle: ChildProcess.ChildProcess, signal: NodeJS.Signals) =>
|
|
108
|
-
Effect.suspend(() =>
|
|
109
|
-
handle.kill(signal) ? Effect.void : Effect.fail(
|
|
110
|
-
toPlatformError("kill", new globalThis.Error("Failed to kill process"), command)
|
|
111
|
-
)
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
return pipe(
|
|
115
|
-
// Validate that the directory is accessible
|
|
116
|
-
Option.match(command.cwd, {
|
|
117
|
-
onNone: () => Effect.void,
|
|
118
|
-
onSome: (dir) => fileSystem.access(dir)
|
|
119
|
-
}),
|
|
120
|
-
Effect.zipRight(
|
|
121
|
-
Effect.acquireRelease(
|
|
122
|
-
spawn,
|
|
123
|
-
([handle, exitCode]) =>
|
|
124
|
-
Effect.flatMap(Deferred.isDone(exitCode), (done) => {
|
|
125
|
-
if (!done) {
|
|
126
|
-
// Process is still running, kill it
|
|
127
|
-
return killProcessGroup(handle, "SIGTERM").pipe(
|
|
128
|
-
Effect.orElse(() => killProcess(handle, "SIGTERM")),
|
|
129
|
-
Effect.zipRight(Deferred.await(exitCode)),
|
|
130
|
-
Effect.ignore
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Process has already exited, check if we need to clean up children
|
|
135
|
-
return Effect.flatMap(Deferred.await(exitCode), ([code]) => {
|
|
136
|
-
if (code !== 0 && code !== null) {
|
|
137
|
-
// Non-zero exit code, attempt to clean up process group
|
|
138
|
-
return killProcessGroup(handle, "SIGTERM").pipe(Effect.ignore)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return Effect.void
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
)
|
|
145
|
-
),
|
|
146
|
-
Effect.map(([handle, exitCodeDeferred]): CommandExecutor.Process => {
|
|
147
|
-
let stdin: Sink.Sink<void, unknown, never, Error.PlatformError> = Sink.drain
|
|
148
|
-
|
|
149
|
-
if (handle.stdin !== null) {
|
|
150
|
-
stdin = fromWritable(
|
|
151
|
-
() => handle.stdin!,
|
|
152
|
-
(err) => toPlatformError("toWritable", toError(err), command)
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const exitCode: CommandExecutor.Process["exitCode"] = Effect.flatMap(
|
|
157
|
-
Deferred.await(exitCodeDeferred),
|
|
158
|
-
([code, signal]) => {
|
|
159
|
-
if (code !== null) {
|
|
160
|
-
return Effect.succeed(CommandExecutor.ExitCode(code))
|
|
161
|
-
}
|
|
162
|
-
// If code is `null`, then `signal` must be defined. See the NodeJS
|
|
163
|
-
// documentation for the `"exit"` event on a `child_process`.
|
|
164
|
-
// https://nodejs.org/api/child_process.html#child_process_event_exit
|
|
165
|
-
return Effect.fail(
|
|
166
|
-
toPlatformError(
|
|
167
|
-
"exitCode",
|
|
168
|
-
new globalThis.Error(`Process interrupted due to receipt of signal: ${signal}`),
|
|
169
|
-
command
|
|
170
|
-
)
|
|
171
|
-
)
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
const isRunning = Effect.negate(Deferred.isDone(exitCodeDeferred))
|
|
176
|
-
|
|
177
|
-
const kill: CommandExecutor.Process["kill"] = (signal = "SIGTERM") =>
|
|
178
|
-
killProcessGroup(handle, signal).pipe(
|
|
179
|
-
Effect.orElse(() => killProcess(handle, signal)),
|
|
180
|
-
Effect.zipRight(Effect.asVoid(Deferred.await(exitCodeDeferred)))
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
const pid = CommandExecutor.ProcessId(handle.pid!)
|
|
184
|
-
const stderr = fromReadable<Error.PlatformError, Uint8Array>(
|
|
185
|
-
() => handle.stderr!,
|
|
186
|
-
(err) => toPlatformError("fromReadable(stderr)", toError(err), command)
|
|
187
|
-
)
|
|
188
|
-
let stdout: Stream.Stream<Uint8Array, Error.PlatformError> = fromReadable<
|
|
189
|
-
Error.PlatformError,
|
|
190
|
-
Uint8Array
|
|
191
|
-
>(
|
|
192
|
-
() => handle.stdout!,
|
|
193
|
-
(err) => toPlatformError("fromReadable(stdout)", toError(err), command)
|
|
194
|
-
)
|
|
195
|
-
// TODO: add Sink.isSink
|
|
196
|
-
if (typeof command.stdout !== "string") {
|
|
197
|
-
stdout = Stream.transduce(stdout, command.stdout)
|
|
198
|
-
}
|
|
199
|
-
return Object.assign(Object.create(ProcessProto), {
|
|
200
|
-
pid,
|
|
201
|
-
exitCode,
|
|
202
|
-
isRunning,
|
|
203
|
-
kill,
|
|
204
|
-
stdin,
|
|
205
|
-
stderr,
|
|
206
|
-
stdout
|
|
207
|
-
})
|
|
208
|
-
}),
|
|
209
|
-
typeof command.stdin === "string"
|
|
210
|
-
? identity
|
|
211
|
-
: Effect.tap((process) =>
|
|
212
|
-
Effect.forkDaemon(Stream.run(command.stdin as Stream.Stream<Uint8Array>, process.stdin))
|
|
213
|
-
)
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
case "PipedCommand": {
|
|
217
|
-
const flattened = Command.flatten(command)
|
|
218
|
-
if (flattened.length === 1) {
|
|
219
|
-
return pipe(flattened[0], runCommand(fileSystem))
|
|
220
|
-
}
|
|
221
|
-
const head = flattened[0]
|
|
222
|
-
const tail = flattened.slice(1)
|
|
223
|
-
const initial = tail.slice(0, tail.length - 1)
|
|
224
|
-
const last = tail[tail.length - 1]
|
|
225
|
-
const stream = initial.reduce(
|
|
226
|
-
(stdin, command) =>
|
|
227
|
-
pipe(
|
|
228
|
-
Command.stdin(command, stdin),
|
|
229
|
-
runCommand(fileSystem),
|
|
230
|
-
Effect.map((process) => process.stdout),
|
|
231
|
-
Stream.unwrapScoped
|
|
232
|
-
),
|
|
233
|
-
pipe(
|
|
234
|
-
runCommand(fileSystem)(head),
|
|
235
|
-
Effect.map((process) => process.stdout),
|
|
236
|
-
Stream.unwrapScoped
|
|
237
|
-
)
|
|
238
|
-
)
|
|
239
|
-
return pipe(Command.stdin(last, stream), runCommand(fileSystem))
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/** @internal */
|
|
245
|
-
export const layer: Layer.Layer<CommandExecutor.CommandExecutor, never, FileSystem.FileSystem> = Layer.effect(
|
|
246
|
-
CommandExecutor.CommandExecutor,
|
|
247
|
-
pipe(
|
|
248
|
-
FileSystem.FileSystem,
|
|
249
|
-
Effect.map((fileSystem) => CommandExecutor.makeExecutor(runCommand(fileSystem)))
|
|
250
|
-
)
|
|
251
|
-
)
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as Error from "@effect/platform/Error"
|
|
2
|
-
import * as FileSystem from "@effect/platform/FileSystem"
|
|
3
|
-
import * as ParcelWatcher from "@parcel/watcher"
|
|
4
|
-
import * as Chunk from "effect/Chunk"
|
|
5
|
-
import * as Effect from "effect/Effect"
|
|
6
|
-
import * as Layer from "effect/Layer"
|
|
7
|
-
import * as Option from "effect/Option"
|
|
8
|
-
import * as Stream from "effect/Stream"
|
|
9
|
-
|
|
10
|
-
const watchParcel = (path: string) =>
|
|
11
|
-
Stream.asyncScoped<FileSystem.WatchEvent, Error.PlatformError>((emit) =>
|
|
12
|
-
Effect.acquireRelease(
|
|
13
|
-
Effect.tryPromise({
|
|
14
|
-
try: () =>
|
|
15
|
-
ParcelWatcher.subscribe(path, (cause, events) => {
|
|
16
|
-
if (cause) {
|
|
17
|
-
emit.fail(
|
|
18
|
-
new Error.SystemError({
|
|
19
|
-
reason: "Unknown",
|
|
20
|
-
module: "FileSystem",
|
|
21
|
-
method: "watch",
|
|
22
|
-
pathOrDescriptor: path,
|
|
23
|
-
cause
|
|
24
|
-
})
|
|
25
|
-
)
|
|
26
|
-
} else {
|
|
27
|
-
emit.chunk(Chunk.unsafeFromArray(events.map((event) => {
|
|
28
|
-
switch (event.type) {
|
|
29
|
-
case "create": {
|
|
30
|
-
return FileSystem.WatchEventCreate({ path: event.path })
|
|
31
|
-
}
|
|
32
|
-
case "update": {
|
|
33
|
-
return FileSystem.WatchEventUpdate({ path: event.path })
|
|
34
|
-
}
|
|
35
|
-
case "delete": {
|
|
36
|
-
return FileSystem.WatchEventRemove({ path: event.path })
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
})))
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
catch: (cause) =>
|
|
43
|
-
new Error.SystemError({
|
|
44
|
-
reason: "Unknown",
|
|
45
|
-
module: "FileSystem",
|
|
46
|
-
method: "watch",
|
|
47
|
-
pathOrDescriptor: path,
|
|
48
|
-
cause
|
|
49
|
-
})
|
|
50
|
-
}),
|
|
51
|
-
(sub) => Effect.promise(() => sub.unsubscribe())
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
const backend = FileSystem.WatchBackend.of({
|
|
56
|
-
register(path, stat, _options) {
|
|
57
|
-
if (stat.type !== "Directory") {
|
|
58
|
-
return Option.none()
|
|
59
|
-
}
|
|
60
|
-
return Option.some(watchParcel(path))
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
export const layer = Layer.succeed(FileSystem.WatchBackend, backend)
|