char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
38d7f6c
main
1import { ObjectFreeze } from "ext:core/primordials" ; 2import { onRuntimeStart } from "ext:core/bootstrap" ; 3import { 4op_process_cwd , 5op_runtime_info , 6op_sys_hostname , 7op_sys_loadavg , 8op_sys_os_release , 9op_sys_uptime , 10} from "ext:core/ops" ; 11import { result } from "ext:file/errors.js" ; 12 13// Live initialization runs before guest modules, including after snapshot restore. 14export const process :{ 15pid :number ; 16args :readonly string []; 17cwd () :string ; 18hostname () :string ; 19osRelease () :string ; 20uptime () :number ; 21loadavg () :[ number , number , number ]; 22} = { 23pid :undefined ! , 24args :undefined ! , 25cwd () { 26return result ( op_process_cwd ()); 27}, 28hostname () { 29return result ( op_sys_hostname ()); 30}, 31osRelease () { 32return result ( op_sys_os_release ()); 33}, 34uptime () { 35return result ( op_sys_uptime ()); 36}, 37loadavg () { 38return result ( op_sys_loadavg ()); 39}, 40}; 41 42export const runtime :{ 43os :"linux" | "macos" | "windows" ; 44arch :"x86_64" | "aarch64" ; 45version :string ; 46v8 :string ; 47} = { 48os :undefined ! , 49arch :undefined ! , 50version :undefined ! , 51v8 :undefined ! , 52}; 53 54onRuntimeStart (() => { 55const info = op_runtime_info (); 56process . pid = info [ 0 ]; 57process . args = ObjectFreeze ( info [ 5 ]); 58runtime . os = info [ 1 ]; 59runtime . arch = info [ 2 ]; 60runtime . version = info [ 3 ]; 61runtime . v8 = info [ 4 ]; 62ObjectFreeze ( process ); 63ObjectFreeze ( runtime ); 64});