Repository navigation
feat(runtime): expand process extension with platform, arch, argv, chdir, exit, and env Proxy - #5694
Open
kernelcraft2099 wants to merge 2 commits into
Open
kernelcraft2099 wants to merge 2 commits into
kernelcraft2099 wants to merge 2 commits into
Conversation
PeterlitsZo
suggested changes
Nov 27, 2026
| /// Get environment variables so as to allow env property (`process.env`) | ||
| fn env(&self) -> impl IntoIterator<Item = (JsString, JsString)>; | ||
| fn env(&self) -> impl IntoIterator<Item = (JsString, JsString)> { | ||
| std::env::vars().map(|(k, v)| (js_string!(k), js_string!(v))) |
There was a problem hiding this comment.
I think you need put the implement in the impl block of StdProcessProvider.
Author
There was a problem hiding this comment.
StdProcessProvider methods were moved into impl ProcessProvider for StdProcessProvider and the cwd change was reverted in 7e1cc0c
| "aix" => "aix", | ||
| other => other, | ||
| }; | ||
| js_string!(platform) |
There was a problem hiding this comment.
Maybe move it into the impl block of StdProcessProvider is a better idea?
| "mips64" => "mipsel", | ||
| other => other, | ||
| }; | ||
| js_string!(arch) |
There was a problem hiding this comment.
How about moving it into the impl block of StdProcessProvider?
|
|
||
| /// Get command-line arguments (`process.argv`) | ||
| fn argv(&self) -> impl IntoIterator<Item = JsString> { | ||
| std::env::args().map(|arg| js_string!(arg)) |
| /// # Errors | ||
| /// Returns an error if the environment variable cannot be set. | ||
| fn set_env(&self, key: &JsString, value: &JsString) -> JsResult<()> { | ||
| // SAFETY: Single-threaded JS context execution in default StdProcessProvider |
| let path = std::env::current_dir().map_err(|e| { | ||
| JsNativeError::typ() | ||
| .with_message(format!("Failed to get current working directory: {e}")) | ||
| })?; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This Pull Request fixes/closes #5692.
It changes the following:
Summary
Expands Boa's
processruntime extension (boa_runtime::process) to provide essential Node.js-compatible process APIs, allowing JavaScript scripts and CLI tools to inspect the host environment, manage the working directory, read arguments, and terminate execution.Closes #5692
Changes
ProcessProvider&StdProcessProvider(core/runtime/src/process/mod.rs):platform()mappingstd::env::consts::OSto Node.js platform identifiers (win32,darwin,linux, etc.).arch()mappingstd::env::consts::ARCHto Node.js architecture names (x64,ia32,arm64, etc.).argv()exposingstd::env::args()as aJsArray.chdir(dir)usingstd::env::set_current_dirwithJsNativeError::typerror propagation.exit(code)delegating tostd::process::exit(code)(defaulting to0when omitted orundefined).set_envandremove_envtrait hooks onProcessProvider.process.envProxywrapper:process.envin aJsProxy(create_env_proxy) withsetanddeletePropertytraps so property assignments and deletions behave cleanly on the environment object.core/runtime/src/process/tests.rs):platform,arch,argv,cwd,chdir,exit, andenvmutations using a mockProcessProvider.Verification
cargo test -p boa_runtime --features processcargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt -- --checkNotes for Reviewers
process.envtraps update the underlying JS target object. Let me know if you would also likeset_trapanddelete_trapto forward mutations throughProcessProvider::set_env/remove_envto mutate host process environment variables directly.