summaryrefslogtreecommitdiff
path: root/std/node
diff options
context:
space:
mode:
Diffstat (limited to 'std/node')
-rw-r--r--std/node/process.ts61
-rw-r--r--std/node/process_test.ts35
2 files changed, 95 insertions, 1 deletions
diff --git a/std/node/process.ts b/std/node/process.ts
index a05a423fd..b42c885c0 100644
--- a/std/node/process.ts
+++ b/std/node/process.ts
@@ -38,6 +38,67 @@ export const process = {
platform,
version,
versions,
+ get stderr() {
+ return {
+ fd: Deno.stderr.rid,
+ get isTTY(): boolean {
+ return Deno.isatty(this.fd);
+ },
+ pipe(_destination: Deno.Writer, _options: { end: boolean }): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ write(_chunk: string | Uint8Array, _callback: Function): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ on(_event: string, _callback: Function): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ };
+ },
+ get stdin() {
+ return {
+ fd: Deno.stdin.rid,
+ get isTTY(): boolean {
+ return Deno.isatty(this.fd);
+ },
+ read(_size: number): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ on(_event: string, _callback: Function): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ };
+ },
+ get stdout() {
+ return {
+ fd: Deno.stdout.rid,
+ get isTTY(): boolean {
+ return Deno.isatty(this.fd);
+ },
+ pipe(_destination: Deno.Writer, _options: { end: boolean }): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ write(_chunk: string | Uint8Array, _callback: Function): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ on(_event: string, _callback: Function): void {
+ // TODO(JayHelton): to be implemented
+ notImplemented();
+ },
+ };
+ },
/** https://nodejs.org/api/process.html#process_process_events */
// on is not exported by node, it is only available within process:
diff --git a/std/node/process_test.ts b/std/node/process_test.ts
index 4055dfd78..a277eaa07 100644
--- a/std/node/process_test.ts
+++ b/std/node/process_test.ts
@@ -18,8 +18,11 @@ Deno.test({
allKeys.delete("process");
// without esm default
allKeys.delete("default");
- // with on, which is not exported via *
+ // with on, stdin, stderr, and stdout, which is not exported via *
allKeys.add("on");
+ allKeys.add("stdin");
+ allKeys.add("stderr");
+ allKeys.add("stdout");
const allStr = Array.from(allKeys).sort().join(" ");
assertEquals(Object.keys(all.default).sort().join(" "), allStr);
assertEquals(Object.keys(all.process).sort().join(" "), allStr);
@@ -130,3 +133,33 @@ Deno.test({
assertEquals(typeof env.PATH, "string");
},
});
+
+Deno.test({
+ name: "process.stdin",
+ fn() {
+ assertEquals(typeof process.stdin.fd, "number");
+ assertEquals(process.stdin.fd, Deno.stdin.rid);
+ // TODO(jayhelton) Uncomment out this assertion once PTY is supported
+ //assert(process.stdin.isTTY);
+ },
+});
+
+Deno.test({
+ name: "process.stdout",
+ fn() {
+ assertEquals(typeof process.stdout.fd, "number");
+ assertEquals(process.stdout.fd, Deno.stdout.rid);
+ // TODO(jayhelton) Uncomment out this assertion once PTY is supported
+ // assert(process.stdout.isTTY);
+ },
+});
+
+Deno.test({
+ name: "process.stderr",
+ fn() {
+ assertEquals(typeof process.stderr.fd, "number");
+ assertEquals(process.stderr.fd, Deno.stderr.rid);
+ // TODO(jayhelton) Uncomment out this assertion once PTY is supported
+ // assert(process.stderr.isTTY);
+ },
+});