123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.import { notImplemented } from "./_utils.ts";
/** https://nodejs.org/api/process.html#process_process_arch */export const arch = Deno.build.arch;
/** https://nodejs.org/api/process.html#process_process_chdir_directory */export const chdir = Deno.chdir;
/** https://nodejs.org/api/process.html#process_process_cwd */export const cwd = Deno.cwd;
/** https://nodejs.org/api/process.html#process_process_exit_code */export const exit = Deno.exit;
/** https://nodejs.org/api/process.html#process_process_pid */export const pid = Deno.pid;
/** https://nodejs.org/api/process.html#process_process_platform */export const platform = Deno.build.os === "windows" ? "win32" : Deno.build.os;
/** https://nodejs.org/api/process.html#process_process_version */export const version = `v${Deno.version.deno}`;
/** https://nodejs.org/api/process.html#process_process_versions */export const versions = { node: Deno.version.deno, ...Deno.version,};
/** https://nodejs.org/api/process.html#process_process */// @deprecated `import { process } from 'process'` for backwards compatibility with old deno versionsexport const process = { arch, chdir, cwd, exit, pid, 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: // node --input-type=module -e "import { on } from 'process'; console.log(on)" // eslint-disable-next-line @typescript-eslint/ban-types on(_event: string, _callback: Function): void { // TODO(rsp): to be implemented notImplemented(); },
/** https://nodejs.org/api/process.html#process_process_argv */ get argv(): string[] { // Getter delegates --allow-env and --allow-read until request // Getter also allows the export Proxy instance to function as intended return [Deno.execPath(), ...Deno.args]; },
/** https://nodejs.org/api/process.html#process_process_env */ get env(): { [index: string]: string } { // Getter delegates --allow-env and --allow-read until request // Getter also allows the export Proxy instance to function as intended return Deno.env.toObject(); },};
/** * https://nodejs.org/api/process.html#process_process_argv * @example `import { argv } from './std/node/process.ts'; console.log(argv)` */// Proxy delegates --allow-env and --allow-read to request time, even for exportsexport const argv = new Proxy(process.argv, {});
/** * https://nodejs.org/api/process.html#process_process_env * @example `import { env } from './std/node/process.ts'; console.log(env)` */// Proxy delegates --allow-env and --allow-read to request time, even for exportsexport const env = new Proxy(process.env, {});
// import process from './std/node/process.ts'export default process;
// Define the type for the global declrationtype Process = typeof process;
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,});
declare global { const process: Process;}