From 1f913f2eb6a2b958a6dadaf67283726ae1321236 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Tue, 28 May 2024 13:20:19 +0200 Subject: [PATCH] fix: empty `process.platform` with `__runtime_js_sources` (#24005) We use the `target` property of the snapshot options to derive `process.platform` and `process.arch` from. This value had an incorrect format when compiled with `__runtime_js_sources` enabled. This PR fixes that so that `process.platform` holds the proper value. Fixes https://github.com/denoland/deno/issues/23164 --- runtime/ops/bootstrap.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs index eb9dbc6e84a655..c5c193ef30d2c5 100644 --- a/runtime/ops/bootstrap.rs +++ b/runtime/ops/bootstrap.rs @@ -42,11 +42,20 @@ pub struct SnapshotOptions { impl Default for SnapshotOptions { fn default() -> Self { + let arch = std::env::consts::ARCH; + let platform = std::env::consts::OS; + let target = match platform { + "macos" => format!("{}-apple-darwin", arch), + "linux" => format!("{}-unknown-linux-gnu", arch), + "windows" => format!("{}-pc-windows-msvc", arch), + rest => format!("{}-{}", arch, rest), + }; + Self { deno_version: "dev".to_owned(), ts_version: "n/a".to_owned(), v8_version: deno_core::v8_version(), - target: std::env::consts::ARCH.to_owned(), + target, } } }