summaryrefslogtreecommitdiff
path: root/std/node/process.ts
diff options
context:
space:
mode:
authorRafaƂ Pocztarski <r.pocztarski@gmail.com>2019-11-19 00:30:24 +0100
committerRy Dahl <ry@tinyclouds.org>2019-11-18 18:30:24 -0500
commit4ca624a355674babbeac093b9b631210ba2f983e (patch)
tree68b87b954e0f753f5b78295c004f7159607d1bb8 /std/node/process.ts
parent542ec461c4f970727d5a7dabeaae27689efb88f3 (diff)
feat: std/node/process (#3368)
Diffstat (limited to 'std/node/process.ts')
-rw-r--r--std/node/process.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/std/node/process.ts b/std/node/process.ts
new file mode 100644
index 000000000..35de23b88
--- /dev/null
+++ b/std/node/process.ts
@@ -0,0 +1,42 @@
+import { notImplemented } from "./_utils.ts";
+
+const version = `v${Deno.version.deno}`;
+
+const versions = {
+ node: Deno.version.deno,
+ ...Deno.version
+};
+
+const osToPlatform = (os: Deno.OperatingSystem): string =>
+ os === "win" ? "win32" : os === "mac" ? "darwin" : os;
+
+const platform = osToPlatform(Deno.build.os);
+
+const { arch } = Deno.build;
+
+const { pid, cwd, chdir, exit } = Deno;
+
+function on(_event: string, _callback: Function): void {
+ // TODO(rsp): to be implemented
+ notImplemented();
+}
+
+export const process = {
+ version,
+ versions,
+ platform,
+ arch,
+ pid,
+ cwd,
+ chdir,
+ exit,
+ on,
+ get env(): { [index: string]: string } {
+ // using getter to avoid --allow-env unless it's used
+ return Deno.env();
+ },
+ get argv(): string[] {
+ // Deno.execPath() also requires --allow-env
+ return [Deno.execPath(), ...Deno.args];
+ }
+};