summaryrefslogtreecommitdiff
path: root/std/node/process.ts
blob: cad72a00ab33b8774b389e07efaf321a1962a44a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { notImplemented } from "./_utils.ts";

function on(_event: string, _callback: Function): void {
  // TODO(rsp): to be implemented
  notImplemented();
}

export const process = {
  version: `v${Deno.version.deno}`,
  versions: {
    node: Deno.version.deno,
    ...Deno.version,
  },
  platform: Deno.build.os === "windows" ? "win32" : Deno.build.os,
  arch: Deno.build.arch,
  pid: Deno.pid,
  cwd: Deno.cwd,
  chdir: Deno.chdir,
  exit: Deno.exit,
  on,
  get env(): { [index: string]: string } {
    // using getter to avoid --allow-env unless it's used
    return Deno.env.toObject();
  },
  get argv(): string[] {
    // Deno.execPath() also requires --allow-env
    return [Deno.execPath(), ...Deno.args];
  },
};

Object.defineProperty(process, Symbol.toStringTag, {
  enumerable: false,
  writable: true,
  configurable: false,
  value: "process",
});

Object.defineProperty(globalThis, "process", {
  value: process,
  enumerable: false,
  writable: true,
  configurable: true,
});