Skip to content

Commit a28b449

Browse files
committed
feat(node): process global improvements
- feat(node): support for `stdin`, `stdout`, `stdin` on `process` - feat(node): support for `process.title` Signed-off-by: Sam Gammon <sam@elide.ventures>
1 parent c6ef223 commit a28b449

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

elide/runtime/js/modules/process/process.ts

+59-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
*/
1919

2020
function intrinsic(): any {
21-
// @ts-expect-error intrinsic symbol
22-
const api = __Elide_node_process__;
23-
if (!api) {
24-
throw new Error(`The 'process' module failed to load the intrinsic API.`);
25-
}
21+
const api = globalThis['__Elide_node_process__'];
22+
if (!api) throw new Error(`The 'process' module failed to load the intrinsic API.`);
2623
return api || {};
2724
}
2825

@@ -81,12 +78,40 @@ export interface NodeProcessAPI {
8178
*/
8279
pid: number;
8380

81+
/**
82+
* Property: `stdout`.
83+
*
84+
* Access to standard output.
85+
*/
86+
stdout: any;
87+
88+
/**
89+
* Property: `stderr`.
90+
*
91+
* Access to standard error output.
92+
*/
93+
stderr: any;
94+
95+
/**
96+
* Property: `stdin`.
97+
*
98+
* Access to standard input.
99+
*/
100+
stdin: any;
101+
102+
/**
103+
* Property: `title`.
104+
*
105+
* Access to the current process title.
106+
*/
107+
title: string;
108+
84109
/**
85110
* Property: `cwd`.
86111
*
87112
* The current working directory.
88113
*/
89-
cwd: string;
114+
cwd: () => string;
90115

91116
/**
92117
* Property: `exit`.
@@ -163,6 +188,34 @@ export const pid = getProcessAPI().pid;
163188
*/
164189
export const cwd = getProcessAPI().cwd;
165190

191+
/**
192+
* Property: `stdout`.
193+
*
194+
* Standard output stream.
195+
*/
196+
export const stdout = getProcessAPI().stdout;
197+
198+
/**
199+
* Property: `stderr`.
200+
*
201+
* Standard error output stream.
202+
*/
203+
export const stderr = getProcessAPI().stderr;
204+
205+
/**
206+
* Property: `stdin`.
207+
*
208+
* Standard input stream.
209+
*/
210+
export const stdin = getProcessAPI().stdin;
211+
212+
/**
213+
* Property: `title`.
214+
*
215+
* Standard input stream.
216+
*/
217+
export const title = getProcessAPI().title;
218+
166219
/**
167220
* Property: `exit`.
168221
*

0 commit comments

Comments
 (0)