Skip to main content

agentmux_common/
platform_name.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The OS name the frontend uses (Node's `process.platform` values), from
5//! Rust's `std::env::consts::OS`.
6
7/// `"darwin"`, `"win32"`, `"linux"`, ... for the OS this process runs on.
8pub fn platform_name() -> &'static str {
9    from_rust_os(std::env::consts::OS)
10}
11
12fn from_rust_os(os: &'static str) -> &'static str {
13    match os {
14        "macos" => "darwin",
15        "windows" => "win32",
16        other => other,
17    }
18}
19
20#[cfg(test)]
21mod tests {
22    use super::*;
23
24    #[test]
25    fn maps_rust_names_to_the_frontend_names() {
26        assert_eq!(from_rust_os("macos"), "darwin");
27        assert_eq!(from_rust_os("windows"), "win32");
28        assert_eq!(from_rust_os("linux"), "linux");
29        assert_eq!(from_rust_os("freebsd"), "freebsd");
30    }
31}