@effect/platform-node 0.19.9 → 0.20.1
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/Command/dist/effect-platform-node-Command.cjs.dev.js +32 -32
- package/Command/dist/effect-platform-node-Command.cjs.prod.js +32 -32
- package/CommandExecutor/dist/effect-platform-node-CommandExecutor.cjs.dev.js +184 -16
- package/CommandExecutor/dist/effect-platform-node-CommandExecutor.cjs.prod.js +184 -16
- package/CommandExecutor/dist/effect-platform-node-CommandExecutor.esm.js +158 -13
- package/Effectify/dist/effect-platform-node-Effectify.cjs.dev.js +2 -2
- package/Effectify/dist/effect-platform-node-Effectify.cjs.prod.js +2 -2
- package/Error/dist/effect-platform-node-Error.cjs.dev.js +6 -6
- package/Error/dist/effect-platform-node-Error.cjs.prod.js +6 -6
- package/FileSystem/dist/effect-platform-node-FileSystem.cjs.dev.js +423 -17
- package/FileSystem/dist/effect-platform-node-FileSystem.cjs.prod.js +423 -17
- package/FileSystem/dist/effect-platform-node-FileSystem.esm.js +395 -12
- package/Http/FormData/dist/effect-platform-node-Http-FormData.cjs.dev.js +3 -3
- package/Http/FormData/dist/effect-platform-node-Http-FormData.cjs.prod.js +3 -3
- package/Http/FormData/dist/effect-platform-node-Http-FormData.esm.js +3 -3
- package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.cjs.dev.js +4 -4
- package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.cjs.prod.js +4 -4
- package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.esm.js +4 -4
- package/Http/Platform/dist/effect-platform-node-Http-Platform.cjs.dev.js +2 -2
- package/Http/Platform/dist/effect-platform-node-Http-Platform.cjs.prod.js +2 -2
- package/Http/Platform/dist/effect-platform-node-Http-Platform.esm.js +2 -2
- package/Http/Server/dist/effect-platform-node-Http-Server.cjs.dev.js +8 -7
- package/Http/Server/dist/effect-platform-node-Http-Server.cjs.prod.js +8 -7
- package/Http/Server/dist/effect-platform-node-Http-Server.esm.js +8 -7
- package/HttpClient/dist/effect-platform-node-HttpClient.cjs.dev.js +19 -19
- package/HttpClient/dist/effect-platform-node-HttpClient.cjs.prod.js +19 -19
- package/HttpClient/dist/effect-platform-node-HttpClient.esm.js +4 -4
- package/HttpServer/dist/effect-platform-node-HttpServer.cjs.dev.js +23 -23
- package/HttpServer/dist/effect-platform-node-HttpServer.cjs.prod.js +23 -23
- package/HttpServer/dist/effect-platform-node-HttpServer.esm.js +8 -8
- package/KeyValueStore/dist/effect-platform-node-KeyValueStore.cjs.dev.js +39 -9
- package/KeyValueStore/dist/effect-platform-node-KeyValueStore.cjs.prod.js +39 -9
- package/KeyValueStore/dist/effect-platform-node-KeyValueStore.esm.js +18 -4
- package/NodeContext/dist/effect-platform-node-NodeContext.cjs.dev.js +39 -7
- package/NodeContext/dist/effect-platform-node-NodeContext.cjs.prod.js +39 -7
- package/NodeContext/dist/effect-platform-node-NodeContext.esm.js +22 -6
- package/Path/dist/effect-platform-node-Path.cjs.dev.js +91 -11
- package/Path/dist/effect-platform-node-Path.cjs.prod.js +91 -11
- package/Path/dist/effect-platform-node-Path.esm.js +68 -6
- package/Runtime/dist/effect-platform-node-Runtime.cjs.dev.js +57 -6
- package/Runtime/dist/effect-platform-node-Runtime.cjs.prod.js +57 -6
- package/Runtime/dist/effect-platform-node-Runtime.esm.js +38 -3
- package/Sink/dist/effect-platform-node-Sink.cjs.dev.js +15 -3
- package/Sink/dist/effect-platform-node-Sink.cjs.prod.js +15 -3
- package/Sink/dist/effect-platform-node-Sink.esm.js +18 -2
- package/Stream/dist/effect-platform-node-Stream.cjs.dev.js +29 -5
- package/Stream/dist/effect-platform-node-Stream.cjs.prod.js +29 -5
- package/Stream/dist/effect-platform-node-Stream.esm.js +30 -2
- package/dist/{FormData-053407d4.cjs.dev.js → FormData-15af6672.cjs.dev.js} +1 -1
- package/dist/{FormData-bafc0b9a.esm.js → FormData-5ea8a8b6.esm.js} +1 -1
- package/dist/{FormData-c7339a7b.cjs.prod.js → FormData-d91e8016.cjs.prod.js} +1 -1
- package/dist/{NodeClient-ea1a9ab0.cjs.prod.js → NodeClient-3432a6a8.cjs.prod.js} +2 -2
- package/dist/{NodeClient-e349733e.esm.js → NodeClient-cd56cae8.esm.js} +2 -2
- package/dist/{NodeClient-1df9d813.cjs.dev.js → NodeClient-ebd71893.cjs.dev.js} +2 -2
- package/dist/{Server-ea100887.cjs.prod.js → Server-5dbcee7b.cjs.prod.js} +7 -5
- package/dist/{Server-264c702d.cjs.dev.js → Server-5f055bfd.cjs.dev.js} +7 -5
- package/dist/{Server-5237fa52.esm.js → Server-c08c825c.esm.js} +6 -5
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/effect-platform-node.cjs.dev.js +58 -86
- package/dist/effect-platform-node.cjs.prod.js +58 -86
- package/dist/effect-platform-node.esm.js +26 -73
- package/dist/{formData-fac89256.cjs.dev.js → formData-632b1146.cjs.dev.js} +1 -1
- package/dist/{formData-4330f230.esm.js → formData-dd75bbe1.esm.js} +1 -1
- package/dist/{formData-09ad7f6d.cjs.prod.js → formData-ecf6742b.cjs.prod.js} +1 -1
- package/dist/{incomingMessage-12764c2c.esm.js → incomingMessage-11c9bea6.esm.js} +1 -1
- package/dist/{incomingMessage-8a9a29f7.cjs.prod.js → incomingMessage-86bcf94d.cjs.dev.js} +1 -1
- package/dist/{incomingMessage-d7f144e7.cjs.dev.js → incomingMessage-f56be93e.cjs.prod.js} +1 -1
- package/dist/{platform-f3d31bb1.esm.js → platform-2c00c2c5.esm.js} +1 -1
- package/dist/{platform-1c31462c.cjs.dev.js → platform-5b27475e.cjs.dev.js} +1 -1
- package/dist/{platform-d09ef04f.cjs.prod.js → platform-80b90f07.cjs.prod.js} +1 -1
- package/package.json +8 -5
- package/src/index.ts +13 -13
- package/src/internal/http/server.ts +8 -1
- package/dist/Command-15b84341.cjs.dev.js +0 -29
- package/dist/Command-2fc875e9.cjs.prod.js +0 -29
- package/dist/Command-56d67f13.esm.js +0 -27
- package/dist/CommandExecutor-b7cb55b8.cjs.dev.js +0 -195
- package/dist/CommandExecutor-bccc7563.cjs.prod.js +0 -195
- package/dist/CommandExecutor-cfc0af4b.esm.js +0 -165
- package/dist/Effectify-1676f59e.cjs.prod.js +0 -14
- package/dist/Effectify-24bba5b0.esm.js +0 -12
- package/dist/Effectify-c94620ca.cjs.dev.js +0 -14
- package/dist/Error-1e8c05fb.esm.js +0 -14
- package/dist/Error-243639ac.cjs.dev.js +0 -16
- package/dist/Error-eaa907c8.cjs.prod.js +0 -16
- package/dist/FileSystem-a207377d.cjs.prod.js +0 -433
- package/dist/FileSystem-d4a3521c.esm.js +0 -403
- package/dist/FileSystem-d7b8eeac.cjs.dev.js +0 -433
- package/dist/HttpClient-11e2237f.esm.js +0 -26
- package/dist/HttpClient-19998c5e.cjs.dev.js +0 -54
- package/dist/HttpClient-1ad217ea.cjs.prod.js +0 -54
- package/dist/HttpServer-08393436.esm.js +0 -34
- package/dist/HttpServer-6652ce27.cjs.dev.js +0 -64
- package/dist/HttpServer-d510f888.cjs.prod.js +0 -64
- package/dist/KeyValueStore-35cb6494.cjs.prod.js +0 -62
- package/dist/KeyValueStore-66bca5fd.esm.js +0 -38
- package/dist/KeyValueStore-af7495b6.cjs.dev.js +0 -62
- package/dist/NodeContext-3c96e955.cjs.dev.js +0 -50
- package/dist/NodeContext-4bca6ed4.esm.js +0 -27
- package/dist/NodeContext-dff7bc0b.cjs.prod.js +0 -50
- package/dist/Path-7a81561f.esm.js +0 -76
- package/dist/Path-bf4c3b07.cjs.prod.js +0 -104
- package/dist/Path-feae3dcf.cjs.dev.js +0 -104
- package/dist/Runtime-3bc7ee1e.esm.js +0 -44
- package/dist/Runtime-6aeac6f0.cjs.dev.js +0 -68
- package/dist/Runtime-e746c66d.cjs.prod.js +0 -68
- package/dist/Sink-536c2b16.cjs.dev.js +0 -26
- package/dist/Sink-554d2819.esm.js +0 -23
- package/dist/Sink-735101fa.cjs.prod.js +0 -26
- package/dist/Stream-2d5b1ece.esm.js +0 -37
- package/dist/Stream-53f57af5.cjs.dev.js +0 -42
- package/dist/Stream-7424efca.cjs.prod.js +0 -42
|
@@ -7,66 +7,66 @@ var Command = require('@effect/platform/Command');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'env', {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return Command.env; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, 'exitCode', {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return Command.exitCode; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, 'feed', {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return Command.feed; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, 'flatten', {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return Command.flatten; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, 'isCommand', {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return Command.isCommand; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, 'lines', {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return Command.lines; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, 'make', {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return Command.make; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, 'pipeTo', {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return Command.pipeTo; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, 'start', {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return Command.start; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, 'stderr', {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return Command.stderr; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, 'stdin', {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return Command.stdin; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, 'stdout', {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return Command.stdout; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, 'stream', {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return Command.stream; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, 'streamLines', {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return Command.streamLines; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, 'string', {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return Command.string; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, 'workingDirectory', {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return Command.workingDirectory; }
|
|
72
72
|
});
|
|
@@ -7,66 +7,66 @@ var Command = require('@effect/platform/Command');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'env', {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return Command.env; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, 'exitCode', {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return Command.exitCode; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, 'feed', {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return Command.feed; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, 'flatten', {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return Command.flatten; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, 'isCommand', {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return Command.isCommand; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, 'lines', {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return Command.lines; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, 'make', {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return Command.make; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, 'pipeTo', {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return Command.pipeTo; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, 'start', {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return Command.start; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, 'stderr', {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return Command.stderr; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, 'stdin', {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return Command.stdin; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, 'stdout', {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return Command.stdout; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, 'stream', {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return Command.stream; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, 'streamLines', {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return Command.streamLines; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, 'string', {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return Command.string; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, 'workingDirectory', {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return Command.workingDirectory; }
|
|
72
72
|
});
|
|
@@ -2,26 +2,194 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var Command = require('@effect/platform/Command');
|
|
6
6
|
var CommandExecutor = require('@effect/platform/CommandExecutor');
|
|
7
|
-
require('@effect/platform/
|
|
8
|
-
require('
|
|
9
|
-
require('effect/
|
|
10
|
-
require('effect/
|
|
11
|
-
require('effect/
|
|
12
|
-
require('effect/
|
|
13
|
-
require('effect/
|
|
14
|
-
require('
|
|
15
|
-
require('
|
|
16
|
-
require('../../dist/
|
|
7
|
+
var FileSystem = require('@effect/platform/FileSystem');
|
|
8
|
+
var Effect = require('effect/Effect');
|
|
9
|
+
var Function = require('effect/Function');
|
|
10
|
+
var Layer = require('effect/Layer');
|
|
11
|
+
var Option = require('effect/Option');
|
|
12
|
+
var Sink = require('effect/Sink');
|
|
13
|
+
var Stream = require('effect/Stream');
|
|
14
|
+
var ChildProcess = require('node:child_process');
|
|
15
|
+
var error = require('../../dist/error-e477c10b.cjs.dev.js');
|
|
16
|
+
var sink = require('../../dist/sink-daf9e0e5.cjs.dev.js');
|
|
17
|
+
var stream = require('../../dist/stream-1456ece0.cjs.dev.js');
|
|
17
18
|
require('@effect/platform/Error');
|
|
18
|
-
require('../../dist/sink-daf9e0e5.cjs.dev.js');
|
|
19
|
-
require('../../dist/stream-1456ece0.cjs.dev.js');
|
|
20
19
|
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n["default"] = e;
|
|
35
|
+
return Object.freeze(n);
|
|
36
|
+
}
|
|
21
37
|
|
|
38
|
+
var Command__namespace = /*#__PURE__*/_interopNamespace(Command);
|
|
39
|
+
var CommandExecutor__namespace = /*#__PURE__*/_interopNamespace(CommandExecutor);
|
|
40
|
+
var FileSystem__namespace = /*#__PURE__*/_interopNamespace(FileSystem);
|
|
41
|
+
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect);
|
|
42
|
+
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer);
|
|
43
|
+
var Option__namespace = /*#__PURE__*/_interopNamespace(Option);
|
|
44
|
+
var Sink__namespace = /*#__PURE__*/_interopNamespace(Sink);
|
|
45
|
+
var Stream__namespace = /*#__PURE__*/_interopNamespace(Stream);
|
|
46
|
+
var ChildProcess__namespace = /*#__PURE__*/_interopNamespace(ChildProcess);
|
|
47
|
+
|
|
48
|
+
const inputToStdioOption = stdin => Option__namespace.match(stdin, {
|
|
49
|
+
onNone: () => "inherit",
|
|
50
|
+
onSome: () => "pipe"
|
|
51
|
+
});
|
|
52
|
+
const outputToStdioOption = output => typeof output === "string" ? output : "pipe";
|
|
53
|
+
const toError = err => err instanceof globalThis.Error ? err : new globalThis.Error(String(err));
|
|
54
|
+
const toPlatformError = (method, error$1, command) => {
|
|
55
|
+
const flattened = Command__namespace.flatten(command).reduce((acc, curr) => {
|
|
56
|
+
const command = `${curr.command} ${curr.args.join(" ")}`;
|
|
57
|
+
return acc.length === 0 ? command : `${acc} | ${command}`;
|
|
58
|
+
}, "");
|
|
59
|
+
return error.handleErrnoException("Command", method)(error$1, [flattened]);
|
|
60
|
+
};
|
|
61
|
+
const runCommand = fileSystem => command => {
|
|
62
|
+
switch (command._tag) {
|
|
63
|
+
case "StandardCommand":
|
|
64
|
+
{
|
|
65
|
+
return Function.pipe(
|
|
66
|
+
// Validate that the directory is accessible
|
|
67
|
+
Option__namespace.match(command.cwd, {
|
|
68
|
+
onNone: () => Effect__namespace.unit,
|
|
69
|
+
onSome: dir => fileSystem.access(dir)
|
|
70
|
+
}), Effect__namespace.zipRight(Effect__namespace.sync(() => globalThis.process.env)), Effect__namespace.flatMap(env => Effect__namespace.async(resume => {
|
|
71
|
+
const handle = ChildProcess__namespace.spawn(command.command, command.args, {
|
|
72
|
+
stdio: [inputToStdioOption(command.stdin), outputToStdioOption(command.stdout), outputToStdioOption(command.stderr)],
|
|
73
|
+
cwd: Option__namespace.getOrElse(command.cwd, Function.constUndefined),
|
|
74
|
+
env: {
|
|
75
|
+
...env,
|
|
76
|
+
...Object.fromEntries(command.env)
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
let exited = false;
|
|
80
|
+
handle.on("exit", () => {
|
|
81
|
+
exited = true;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// If starting the process throws an error, make sure to capture it
|
|
85
|
+
handle.on("error", err => {
|
|
86
|
+
handle.kill("SIGKILL");
|
|
87
|
+
resume(Effect__namespace.fail(toPlatformError("spawn", err, command)));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// If the process is assigned a process identifier, then we know it
|
|
91
|
+
// was spawned successfully
|
|
92
|
+
if (handle.pid) {
|
|
93
|
+
let stdin = Sink__namespace.drain;
|
|
94
|
+
if (handle.stdin !== null) {
|
|
95
|
+
stdin = sink.fromWritable(() => handle.stdin, err => toPlatformError("toWritable", toError(err), command));
|
|
96
|
+
}
|
|
97
|
+
const exitCode = Effect__namespace.async(resume => {
|
|
98
|
+
if (exited) {
|
|
99
|
+
return resume(handle.exitCode !== null ? Effect__namespace.succeed(CommandExecutor__namespace.ExitCode(handle.exitCode)) : Effect__namespace.fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: ${handle.signalCode}`), command)));
|
|
100
|
+
}
|
|
101
|
+
handle.on("exit", (code, signal) => {
|
|
102
|
+
if (code !== null) {
|
|
103
|
+
resume(Effect__namespace.succeed(CommandExecutor__namespace.ExitCode(code)));
|
|
104
|
+
} else {
|
|
105
|
+
// If code is `null`, then `signal` must be defined. See the NodeJS
|
|
106
|
+
// documentation for the `"exit"` event on a `child_process`.
|
|
107
|
+
// https://nodejs.org/api/child_process.html#child_process_event_exit
|
|
108
|
+
resume(Effect__namespace.fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: ${signal}`), command)));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
// Make sure to terminate the running process if the fiber is
|
|
112
|
+
// terminated
|
|
113
|
+
return Effect__namespace.sync(() => {
|
|
114
|
+
handle.kill("SIGKILL");
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const isRunning = Effect__namespace.sync(() => handle.exitCode === null && handle.signalCode === null && !handle.killed);
|
|
118
|
+
const kill = (signal = "SIGTERM") => Effect__namespace.async(resume => {
|
|
119
|
+
handle.kill(signal);
|
|
120
|
+
handle.on("exit", () => {
|
|
121
|
+
resume(Effect__namespace.unit);
|
|
122
|
+
});
|
|
123
|
+
// Make sure to terminate the running process if the fiber
|
|
124
|
+
// is terminated
|
|
125
|
+
return Effect__namespace.sync(() => {
|
|
126
|
+
handle.kill("SIGKILL");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
resume(Effect__namespace.sync(() => {
|
|
130
|
+
const pid = CommandExecutor__namespace.ProcessId(handle.pid);
|
|
131
|
+
const stderr = stream.fromReadable(() => handle.stderr, err => toPlatformError("fromReadable(stderr)", toError(err), command));
|
|
132
|
+
let stdout = stream.fromReadable(() => handle.stdout, err => toPlatformError("fromReadable(stdout)", toError(err), command));
|
|
133
|
+
// TODO: add Sink.isSink
|
|
134
|
+
if (typeof command.stdout !== "string") {
|
|
135
|
+
stdout = Stream__namespace.transduce(stdout, command.stdout);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
[CommandExecutor__namespace.ProcessTypeId]: CommandExecutor__namespace.ProcessTypeId,
|
|
139
|
+
pid,
|
|
140
|
+
exitCode,
|
|
141
|
+
isRunning,
|
|
142
|
+
kill,
|
|
143
|
+
stdin,
|
|
144
|
+
stderr,
|
|
145
|
+
stdout
|
|
146
|
+
};
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return Effect__namespace.async(resume => {
|
|
150
|
+
if (handle.pid) {
|
|
151
|
+
handle.kill("SIGTERM");
|
|
152
|
+
}
|
|
153
|
+
handle.on("exit", () => {
|
|
154
|
+
resume(Effect__namespace.unit);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
})), Effect__namespace.tap(process => Option__namespace.match(command.stdin, {
|
|
158
|
+
onNone: () => Effect__namespace.unit,
|
|
159
|
+
onSome: stdin => Effect__namespace.forkDaemon(Stream__namespace.run(stdin, process.stdin))
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
case "PipedCommand":
|
|
163
|
+
{
|
|
164
|
+
const flattened = Command__namespace.flatten(command);
|
|
165
|
+
if (flattened.length === 1) {
|
|
166
|
+
return Function.pipe(flattened[0], runCommand(fileSystem));
|
|
167
|
+
}
|
|
168
|
+
const head = flattened[0];
|
|
169
|
+
const tail = flattened.slice(1);
|
|
170
|
+
const initial = tail.slice(0, tail.length - 1);
|
|
171
|
+
const last = tail[tail.length - 1];
|
|
172
|
+
const stream = initial.reduce((stdin, command) => Function.pipe(Command__namespace.stdin(command, stdin), runCommand(fileSystem), Stream__namespace.flatMap(process => process.stdout)), Function.pipe(runCommand(fileSystem)(head), Stream__namespace.flatMap(process => process.stdout)));
|
|
173
|
+
return Function.pipe(Command__namespace.stdin(last, stream), runCommand(fileSystem));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** @internal */
|
|
179
|
+
const layer$1 = /*#__PURE__*/Layer__namespace.effect(CommandExecutor__namespace.CommandExecutor, /*#__PURE__*/Function.pipe(FileSystem__namespace.FileSystem, /*#__PURE__*/Effect__namespace.map(fileSystem => CommandExecutor__namespace.makeExecutor(runCommand(fileSystem)))));
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @since 1.0.0
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @since 1.0.0
|
|
187
|
+
* @category layer
|
|
188
|
+
*/
|
|
189
|
+
const layer = layer$1;
|
|
22
190
|
|
|
23
|
-
exports.layer = CommandExecutor_dist_effectPlatformNodeCommandExecutor.layer;
|
|
24
191
|
Object.defineProperty(exports, 'CommandExecutor', {
|
|
25
|
-
|
|
26
|
-
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get: function () { return CommandExecutor.CommandExecutor; }
|
|
27
194
|
});
|
|
195
|
+
exports.layer = layer;
|
|
@@ -2,26 +2,194 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var Command = require('@effect/platform/Command');
|
|
6
6
|
var CommandExecutor = require('@effect/platform/CommandExecutor');
|
|
7
|
-
require('@effect/platform/
|
|
8
|
-
require('
|
|
9
|
-
require('effect/
|
|
10
|
-
require('effect/
|
|
11
|
-
require('effect/
|
|
12
|
-
require('effect/
|
|
13
|
-
require('effect/
|
|
14
|
-
require('
|
|
15
|
-
require('
|
|
16
|
-
require('../../dist/
|
|
7
|
+
var FileSystem = require('@effect/platform/FileSystem');
|
|
8
|
+
var Effect = require('effect/Effect');
|
|
9
|
+
var Function = require('effect/Function');
|
|
10
|
+
var Layer = require('effect/Layer');
|
|
11
|
+
var Option = require('effect/Option');
|
|
12
|
+
var Sink = require('effect/Sink');
|
|
13
|
+
var Stream = require('effect/Stream');
|
|
14
|
+
var ChildProcess = require('node:child_process');
|
|
15
|
+
var error = require('../../dist/error-4f074a3a.cjs.prod.js');
|
|
16
|
+
var sink = require('../../dist/sink-da49e187.cjs.prod.js');
|
|
17
|
+
var stream = require('../../dist/stream-ef8b6a66.cjs.prod.js');
|
|
17
18
|
require('@effect/platform/Error');
|
|
18
|
-
require('../../dist/sink-da49e187.cjs.prod.js');
|
|
19
|
-
require('../../dist/stream-ef8b6a66.cjs.prod.js');
|
|
20
19
|
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n["default"] = e;
|
|
35
|
+
return Object.freeze(n);
|
|
36
|
+
}
|
|
21
37
|
|
|
38
|
+
var Command__namespace = /*#__PURE__*/_interopNamespace(Command);
|
|
39
|
+
var CommandExecutor__namespace = /*#__PURE__*/_interopNamespace(CommandExecutor);
|
|
40
|
+
var FileSystem__namespace = /*#__PURE__*/_interopNamespace(FileSystem);
|
|
41
|
+
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect);
|
|
42
|
+
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer);
|
|
43
|
+
var Option__namespace = /*#__PURE__*/_interopNamespace(Option);
|
|
44
|
+
var Sink__namespace = /*#__PURE__*/_interopNamespace(Sink);
|
|
45
|
+
var Stream__namespace = /*#__PURE__*/_interopNamespace(Stream);
|
|
46
|
+
var ChildProcess__namespace = /*#__PURE__*/_interopNamespace(ChildProcess);
|
|
47
|
+
|
|
48
|
+
const inputToStdioOption = stdin => Option__namespace.match(stdin, {
|
|
49
|
+
onNone: () => "inherit",
|
|
50
|
+
onSome: () => "pipe"
|
|
51
|
+
});
|
|
52
|
+
const outputToStdioOption = output => typeof output === "string" ? output : "pipe";
|
|
53
|
+
const toError = err => err instanceof globalThis.Error ? err : new globalThis.Error(String(err));
|
|
54
|
+
const toPlatformError = (method, error$1, command) => {
|
|
55
|
+
const flattened = Command__namespace.flatten(command).reduce((acc, curr) => {
|
|
56
|
+
const command = `${curr.command} ${curr.args.join(" ")}`;
|
|
57
|
+
return acc.length === 0 ? command : `${acc} | ${command}`;
|
|
58
|
+
}, "");
|
|
59
|
+
return error.handleErrnoException("Command", method)(error$1, [flattened]);
|
|
60
|
+
};
|
|
61
|
+
const runCommand = fileSystem => command => {
|
|
62
|
+
switch (command._tag) {
|
|
63
|
+
case "StandardCommand":
|
|
64
|
+
{
|
|
65
|
+
return Function.pipe(
|
|
66
|
+
// Validate that the directory is accessible
|
|
67
|
+
Option__namespace.match(command.cwd, {
|
|
68
|
+
onNone: () => Effect__namespace.unit,
|
|
69
|
+
onSome: dir => fileSystem.access(dir)
|
|
70
|
+
}), Effect__namespace.zipRight(Effect__namespace.sync(() => globalThis.process.env)), Effect__namespace.flatMap(env => Effect__namespace.async(resume => {
|
|
71
|
+
const handle = ChildProcess__namespace.spawn(command.command, command.args, {
|
|
72
|
+
stdio: [inputToStdioOption(command.stdin), outputToStdioOption(command.stdout), outputToStdioOption(command.stderr)],
|
|
73
|
+
cwd: Option__namespace.getOrElse(command.cwd, Function.constUndefined),
|
|
74
|
+
env: {
|
|
75
|
+
...env,
|
|
76
|
+
...Object.fromEntries(command.env)
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
let exited = false;
|
|
80
|
+
handle.on("exit", () => {
|
|
81
|
+
exited = true;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// If starting the process throws an error, make sure to capture it
|
|
85
|
+
handle.on("error", err => {
|
|
86
|
+
handle.kill("SIGKILL");
|
|
87
|
+
resume(Effect__namespace.fail(toPlatformError("spawn", err, command)));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// If the process is assigned a process identifier, then we know it
|
|
91
|
+
// was spawned successfully
|
|
92
|
+
if (handle.pid) {
|
|
93
|
+
let stdin = Sink__namespace.drain;
|
|
94
|
+
if (handle.stdin !== null) {
|
|
95
|
+
stdin = sink.fromWritable(() => handle.stdin, err => toPlatformError("toWritable", toError(err), command));
|
|
96
|
+
}
|
|
97
|
+
const exitCode = Effect__namespace.async(resume => {
|
|
98
|
+
if (exited) {
|
|
99
|
+
return resume(handle.exitCode !== null ? Effect__namespace.succeed(CommandExecutor__namespace.ExitCode(handle.exitCode)) : Effect__namespace.fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: ${handle.signalCode}`), command)));
|
|
100
|
+
}
|
|
101
|
+
handle.on("exit", (code, signal) => {
|
|
102
|
+
if (code !== null) {
|
|
103
|
+
resume(Effect__namespace.succeed(CommandExecutor__namespace.ExitCode(code)));
|
|
104
|
+
} else {
|
|
105
|
+
// If code is `null`, then `signal` must be defined. See the NodeJS
|
|
106
|
+
// documentation for the `"exit"` event on a `child_process`.
|
|
107
|
+
// https://nodejs.org/api/child_process.html#child_process_event_exit
|
|
108
|
+
resume(Effect__namespace.fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: ${signal}`), command)));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
// Make sure to terminate the running process if the fiber is
|
|
112
|
+
// terminated
|
|
113
|
+
return Effect__namespace.sync(() => {
|
|
114
|
+
handle.kill("SIGKILL");
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const isRunning = Effect__namespace.sync(() => handle.exitCode === null && handle.signalCode === null && !handle.killed);
|
|
118
|
+
const kill = (signal = "SIGTERM") => Effect__namespace.async(resume => {
|
|
119
|
+
handle.kill(signal);
|
|
120
|
+
handle.on("exit", () => {
|
|
121
|
+
resume(Effect__namespace.unit);
|
|
122
|
+
});
|
|
123
|
+
// Make sure to terminate the running process if the fiber
|
|
124
|
+
// is terminated
|
|
125
|
+
return Effect__namespace.sync(() => {
|
|
126
|
+
handle.kill("SIGKILL");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
resume(Effect__namespace.sync(() => {
|
|
130
|
+
const pid = CommandExecutor__namespace.ProcessId(handle.pid);
|
|
131
|
+
const stderr = stream.fromReadable(() => handle.stderr, err => toPlatformError("fromReadable(stderr)", toError(err), command));
|
|
132
|
+
let stdout = stream.fromReadable(() => handle.stdout, err => toPlatformError("fromReadable(stdout)", toError(err), command));
|
|
133
|
+
// TODO: add Sink.isSink
|
|
134
|
+
if (typeof command.stdout !== "string") {
|
|
135
|
+
stdout = Stream__namespace.transduce(stdout, command.stdout);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
[CommandExecutor__namespace.ProcessTypeId]: CommandExecutor__namespace.ProcessTypeId,
|
|
139
|
+
pid,
|
|
140
|
+
exitCode,
|
|
141
|
+
isRunning,
|
|
142
|
+
kill,
|
|
143
|
+
stdin,
|
|
144
|
+
stderr,
|
|
145
|
+
stdout
|
|
146
|
+
};
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return Effect__namespace.async(resume => {
|
|
150
|
+
if (handle.pid) {
|
|
151
|
+
handle.kill("SIGTERM");
|
|
152
|
+
}
|
|
153
|
+
handle.on("exit", () => {
|
|
154
|
+
resume(Effect__namespace.unit);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
})), Effect__namespace.tap(process => Option__namespace.match(command.stdin, {
|
|
158
|
+
onNone: () => Effect__namespace.unit,
|
|
159
|
+
onSome: stdin => Effect__namespace.forkDaemon(Stream__namespace.run(stdin, process.stdin))
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
case "PipedCommand":
|
|
163
|
+
{
|
|
164
|
+
const flattened = Command__namespace.flatten(command);
|
|
165
|
+
if (flattened.length === 1) {
|
|
166
|
+
return Function.pipe(flattened[0], runCommand(fileSystem));
|
|
167
|
+
}
|
|
168
|
+
const head = flattened[0];
|
|
169
|
+
const tail = flattened.slice(1);
|
|
170
|
+
const initial = tail.slice(0, tail.length - 1);
|
|
171
|
+
const last = tail[tail.length - 1];
|
|
172
|
+
const stream = initial.reduce((stdin, command) => Function.pipe(Command__namespace.stdin(command, stdin), runCommand(fileSystem), Stream__namespace.flatMap(process => process.stdout)), Function.pipe(runCommand(fileSystem)(head), Stream__namespace.flatMap(process => process.stdout)));
|
|
173
|
+
return Function.pipe(Command__namespace.stdin(last, stream), runCommand(fileSystem));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** @internal */
|
|
179
|
+
const layer$1 = /*#__PURE__*/Layer__namespace.effect(CommandExecutor__namespace.CommandExecutor, /*#__PURE__*/Function.pipe(FileSystem__namespace.FileSystem, /*#__PURE__*/Effect__namespace.map(fileSystem => CommandExecutor__namespace.makeExecutor(runCommand(fileSystem)))));
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @since 1.0.0
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @since 1.0.0
|
|
187
|
+
* @category layer
|
|
188
|
+
*/
|
|
189
|
+
const layer = layer$1;
|
|
22
190
|
|
|
23
|
-
exports.layer = CommandExecutor_dist_effectPlatformNodeCommandExecutor.layer;
|
|
24
191
|
Object.defineProperty(exports, 'CommandExecutor', {
|
|
25
|
-
|
|
26
|
-
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get: function () { return CommandExecutor.CommandExecutor; }
|
|
27
194
|
});
|
|
195
|
+
exports.layer = layer;
|