Skip to content

Commit

Permalink
refactor: remove use of home crate (#27516)
Browse files Browse the repository at this point in the history
The two places mentioned in the issue are now consolidated.

Closes #24385
  • Loading branch information
dsherret authored Jan 2, 2025
1 parent 225c3de commit 0457c38
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
21 changes: 4 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ url = { version = "2.5", features = ["serde", "expose_internals"] }
uuid = { version = "1.3.0", features = ["v4"] }
webpki-root-certs = "0.26.5"
webpki-roots = "0.26"
which = "4.2.5"
which = "6"
yoke = { version = "0.7.4", features = ["derive"] }
zeromq = { version = "=0.4.1", default-features = false, features = ["tcp-transport", "tokio-runtime"] }
zstd = "=0.12.4"
Expand Down
3 changes: 1 addition & 2 deletions ext/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ errno = "0.2.8"
faster-hex.workspace = true
h2.workspace = true
hkdf.workspace = true
home = "0.5.9"
http.workspace = true
http-body-util.workspace = true
hyper.workspace = true
Expand Down Expand Up @@ -93,7 +92,7 @@ simd-json = "0.14.0"
sm3 = "0.4.2"
spki.workspace = true
stable_deref_trait = "1.2.0"
sys_traits = { workspace = true, features = ["real"] }
sys_traits = { workspace = true, features = ["real", "winapi", "libc"] }
thiserror.workspace = true
tokio.workspace = true
tokio-eld = "0.2"
Expand Down
7 changes: 6 additions & 1 deletion ext/node/ops/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::mem::MaybeUninit;

use deno_core::op2;
use deno_core::OpState;
use sys_traits::EnvHomeDir;

use crate::NodePermissions;

Expand Down Expand Up @@ -282,5 +283,9 @@ where
permissions.check_sys("homedir", "node:os.homedir()")?;
}

Ok(home::home_dir().map(|path| path.to_string_lossy().to_string()))
Ok(
sys_traits::impls::RealSys
.env_home_dir()
.map(|path| path.to_string_lossy().to_string()),
)
}
3 changes: 1 addition & 2 deletions runtime/permissions/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,11 +1510,10 @@ impl AllowRunDescriptor {
match which::which_in(text, std::env::var_os("PATH"), cwd) {
Ok(path) => path,
Err(err) => match err {
which::Error::BadAbsolutePath | which::Error::BadRelativePath => {
which::Error::CannotGetCurrentDirAndPathListEmpty => {
return Err(err);
}
which::Error::CannotFindBinaryPath
| which::Error::CannotGetCurrentDir
| which::Error::CannotCanonicalize => {
return Ok(AllowRunDescriptorParseResult::Unresolved(Box::new(err)))
}
Expand Down

0 comments on commit 0457c38

Please sign in to comment.