@gjsify/child_process 0.29.0 → 0.31.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/lib/types/commands.spec.d.ts +111 -0
- package/package.json +17 -8
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** `[file, args]`, ready to spread into `spawn(…)` / `execFile(…)`. */
|
|
2
|
+
export type Command = readonly [file: string, args: string[]];
|
|
3
|
+
/**
|
|
4
|
+
* The interpreter this suite is running on — `process.execPath`, whatever that
|
|
5
|
+
* is here. Exported because the argv0 specs assert the child's default `argv[0]`
|
|
6
|
+
* against it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const INTERPRETER: string;
|
|
9
|
+
/**
|
|
10
|
+
* Print the child's `argv[0]` — the portable stand-in for `sh -c 'echo "$0"'`.
|
|
11
|
+
*
|
|
12
|
+
* The argv0 specs used the SHELL's `$0` to read back what `options.argv0` set.
|
|
13
|
+
* Node exposes the same value as `process.argv0`; GJS exposes it as
|
|
14
|
+
* `imports.system.programInvocationName`, which under `-c` (no script to name)
|
|
15
|
+
* is argv[0] itself. `GLib.get_prgname()` is NOT usable here — it is the
|
|
16
|
+
* BASENAME, so it would silently pass the overridden-argv0 assertion and fail
|
|
17
|
+
* the default one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function printArgv0(): Command;
|
|
20
|
+
/**
|
|
21
|
+
* Print `text` and a newline to stdout, then exit 0 — `echo <text>`.
|
|
22
|
+
*
|
|
23
|
+
* The text travels as an ARGV entry rather than being interpolated into the
|
|
24
|
+
* source: the specs echo values containing spaces and quotes, and building a
|
|
25
|
+
* command STRING out of those is the injection-shaped mistake the repo's own
|
|
26
|
+
* rules call out ("pass an argv array, never an interpolated command line").
|
|
27
|
+
*/
|
|
28
|
+
export declare function echo(...text: string[]): Command;
|
|
29
|
+
/** Print the same as `echo`, but to stderr. */
|
|
30
|
+
export declare function echoErr(...text: string[]): Command;
|
|
31
|
+
/** Print the process's working directory, no trailing newline — `pwd`. */
|
|
32
|
+
export declare function pwd(): Command;
|
|
33
|
+
/** Copy stdin to stdout until EOF — `cat`. */
|
|
34
|
+
export declare function cat(): Command;
|
|
35
|
+
/** Print one environment variable, or the empty string when it is unset. */
|
|
36
|
+
export declare function printEnv(name: string): Command;
|
|
37
|
+
/** Print the integers `from`..`to`, one per line — `seq`. */
|
|
38
|
+
export declare function seq(from: number, to: number): Command;
|
|
39
|
+
/**
|
|
40
|
+
* Stay alive for `ms` milliseconds, then exit 0 — `sleep`.
|
|
41
|
+
*
|
|
42
|
+
* GJS blocks in `g_usleep()` rather than arming a main loop: the sleeping child
|
|
43
|
+
* is a KILL TARGET in these specs (timeouts, `AbortSignal`, `SIGKILL`), and a
|
|
44
|
+
* blocked process is killed exactly like an idle one while needing no loop to
|
|
45
|
+
* be running for the signal to land.
|
|
46
|
+
*/
|
|
47
|
+
export declare function sleep(ms: number): Command;
|
|
48
|
+
/** Exit 0 immediately — `true`. */
|
|
49
|
+
export declare function exitOk(): Command;
|
|
50
|
+
/** Exit with `code` — `false` is `exitWith(1)`. */
|
|
51
|
+
export declare function exitWith(code: number): Command;
|
|
52
|
+
/** Write `text` to stderr, then exit with `code`. */
|
|
53
|
+
export declare function failWith(code: number, text: string): Command;
|
|
54
|
+
/** Write `count` bytes to stdout — the `maxBuffer` specs' subject. */
|
|
55
|
+
export declare function emitBytes(count: number): Command;
|
|
56
|
+
/** Read all of stdin and print it upper-cased, trimmed — the pipeline specs' sink. */
|
|
57
|
+
export declare function upperFromStdin(): Command;
|
|
58
|
+
/**
|
|
59
|
+
* Expand a shell-style template against the environment and print the result —
|
|
60
|
+
* the portable stand-in for `sh -c 'echo "VAL=$VAL"'`.
|
|
61
|
+
*
|
|
62
|
+
* The env-coercion specs are the reason this exists. Their SUBJECT is what
|
|
63
|
+
* `spawn` does to an `env` object whose values are not strings (`undefined` is
|
|
64
|
+
* dropped, `null` becomes `"null"`, a number becomes its decimal string, an
|
|
65
|
+
* array is comma-joined, and prototype-chain keys still propagate because Node
|
|
66
|
+
* walks with `for…in`). Reading the result back needed a child that prints an
|
|
67
|
+
* environment variable, and `sh` was simply the shortest way to write one — so
|
|
68
|
+
* ten assertions about ENV ended up depending on a POSIX shell.
|
|
69
|
+
*
|
|
70
|
+
* Supports `$NAME` and POSIX `${NAME:-default}`, which substitutes when the
|
|
71
|
+
* variable is unset OR empty. That is the whole grammar those specs use.
|
|
72
|
+
*/
|
|
73
|
+
export declare function printEnvTemplate(template: string): Command;
|
|
74
|
+
/**
|
|
75
|
+
* Print an environment variable and a newline, then copy stdin to stdout — the
|
|
76
|
+
* stand-in for `sh -c 'echo $VAR; cat'`, whose subject is that BOTH pipes are
|
|
77
|
+
* live when `env` carries an `undefined` value.
|
|
78
|
+
*/
|
|
79
|
+
export declare function printEnvThenCat(name: string): Command;
|
|
80
|
+
/** Print an environment variable, then the working directory on the next line. */
|
|
81
|
+
export declare function printEnvThenPwd(name: string): Command;
|
|
82
|
+
/** Running under a `cmd.exe` shell rather than a POSIX one? */
|
|
83
|
+
export declare const SHELL_IS_CMD: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* libuv's `ENOENT`, which is NOT the same number on every OS.
|
|
86
|
+
*
|
|
87
|
+
* libuv gives Windows its own errno space: `UV_ENOENT` is -4058 there against
|
|
88
|
+
* -2 on POSIX. `err.code` (`'ENOENT'`) is the portable half and is what a
|
|
89
|
+
* consumer should branch on; the number is asserted here because Node exposes
|
|
90
|
+
* it and a regression in it would be real.
|
|
91
|
+
*/
|
|
92
|
+
export declare const UV_ENOENT: number;
|
|
93
|
+
/** The shell built-in that prints the working directory. */
|
|
94
|
+
export declare const SHELL_PWD: string;
|
|
95
|
+
/** Shell expansion of an environment variable, in the host shell's grammar. */
|
|
96
|
+
export declare function shellVar(name: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* A shell COMMAND LINE that runs one of the commands above — for the cases
|
|
99
|
+
* where no built-in exists on both shells (`tr`, `printf`, `seq`, `cat`).
|
|
100
|
+
*
|
|
101
|
+
* DERIVED from the `Command`, never a third hand-written source: that is what
|
|
102
|
+
* keeps the shell path and the spawn path exercising the same program, and it
|
|
103
|
+
* is why `setTimeout(() => {}, 10000)` no longer appears five times in
|
|
104
|
+
* `parity.spec.ts`.
|
|
105
|
+
*
|
|
106
|
+
* Every token is double-quoted, which is what makes one command line valid
|
|
107
|
+
* under `/bin/sh` and `cmd.exe` alike, and it also covers an executable path
|
|
108
|
+
* containing spaces (`C:\Program Files\nodejs\node.exe`). The sources above are
|
|
109
|
+
* written with single quotes precisely so this wrapping is lossless.
|
|
110
|
+
*/
|
|
111
|
+
export declare function shellCmd([file, args]: Command): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/child_process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Node.js child_process module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"child_process"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@gjsify/cli": "^0.
|
|
41
|
-
"@gjsify/dom-elements": "^0.
|
|
42
|
-
"@gjsify/unit": "^0.
|
|
40
|
+
"@gjsify/cli": "^0.31.0",
|
|
41
|
+
"@gjsify/dom-elements": "^0.31.0",
|
|
42
|
+
"@gjsify/unit": "^0.31.0",
|
|
43
43
|
"@types/node": "^25.9.2",
|
|
44
44
|
"typescript": "^6.0.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@girs/gio-2.0": "^4.1.0",
|
|
48
48
|
"@girs/glib-2.0": "^4.1.0",
|
|
49
|
-
"@gjsify/buffer": "^0.
|
|
50
|
-
"@gjsify/events": "^0.
|
|
51
|
-
"@gjsify/utils": "^0.
|
|
49
|
+
"@gjsify/buffer": "^0.31.0",
|
|
50
|
+
"@gjsify/events": "^0.31.0",
|
|
51
|
+
"@gjsify/utils": "^0.31.0"
|
|
52
52
|
},
|
|
53
53
|
"gjsify": {
|
|
54
54
|
"runtimes": {
|
|
@@ -57,7 +57,16 @@
|
|
|
57
57
|
"browser": "none",
|
|
58
58
|
"nativescript": "none"
|
|
59
59
|
},
|
|
60
|
-
"tier": 1
|
|
60
|
+
"tier": 1,
|
|
61
|
+
"os": {
|
|
62
|
+
"linux": "supported",
|
|
63
|
+
"darwin": "partial",
|
|
64
|
+
"win32": "partial"
|
|
65
|
+
},
|
|
66
|
+
"osNotes": {
|
|
67
|
+
"darwin": "`detached: true` degrades. macOS ships no `setsid(1)` (it is a util-linux tool) and `setsid(2)` is unreachable from JS because `g_subprocess_launcher_set_child_setup()` is not introspectable, so `detachedPrefix()` returns `null` unless the user installed one. The child is still spawned and still outlives its parent, but it stays in the parent's process group, so terminal-generated SIGINT/SIGHUP still reach it — see `src/platform/darwin.ts`. Everything else in the package is exercised on darwin by `macos-suites.yml`, including the BSD signal table and the in-process `communicate.ts` timeout that replaced GNU `timeout(1)` for this platform.",
|
|
68
|
+
"win32": "A `src/platform/win32.ts` exists and is written against Node's documented Windows behaviour, but NOTHING RUNS IT. The package declares `runtimes.node: \"none\"`, so `test:node` exercises native Node rather than this implementation, and `test:gjs` — the leg that would measure it — cannot run on Windows at all because there is no GJS host there. The win32 module is therefore unexercised code, not a verified port. Promote to `supported` when a leg executes it."
|
|
69
|
+
}
|
|
61
70
|
},
|
|
62
71
|
"license": "MIT",
|
|
63
72
|
"repository": {
|