diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-05-28 13:20:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 13:20:19 +0200 |
commit | 1f913f2eb6a2b958a6dadaf67283726ae1321236 (patch) | |
tree | 84eae198815cb9a0cac7ef6a5c4f4f7c97de4e6e | |
parent | a0ddf7305895e2920ef5d9208fc9ec767ebb11d5 (diff) |
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
-rw-r--r-- | runtime/ops/bootstrap.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs index eb9dbc6e8..c5c193ef3 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, } } } |