From fb08cf7005c9dc781d51c7d02ae06060e44d32a3 Mon Sep 17 00:00:00 2001 From: ecyrbe Date: Mon, 24 Feb 2020 14:35:45 +0100 Subject: Add missing node os.release() implementation (#4065) --- cli/ops/os.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'cli/ops') diff --git a/cli/ops/os.rs b/cli/ops/os.rs index 10c5e247e..8e4f1e95d 100644 --- a/cli/ops/os.rs +++ b/cli/ops/os.rs @@ -21,6 +21,10 @@ pub fn init(i: &mut Isolate, s: &State) { i.register_op("get_dir", s.core_op(json_op(s.stateful_op(op_get_dir)))); i.register_op("hostname", s.core_op(json_op(s.stateful_op(op_hostname)))); i.register_op("loadavg", s.core_op(json_op(s.stateful_op(op_loadavg)))); + i.register_op( + "os_release", + s.core_op(json_op(s.stateful_op(op_os_release))), + ); } #[derive(Deserialize)] @@ -185,6 +189,16 @@ fn op_hostname( _zero_copy: Option, ) -> Result { state.check_env()?; - let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_owned()); + let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string()); Ok(JsonOp::Sync(json!(hostname))) } + +fn op_os_release( + state: &State, + _args: Value, + _zero_copy: Option, +) -> Result { + state.check_env()?; + let release = sys_info::os_release().unwrap_or_else(|_| "".to_string()); + Ok(JsonOp::Sync(json!(release))) +} -- cgit v1.2.3