mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
refactor: allow deno_permissions to compile to wasm32-unknown-unknown (#29487)
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build wasm32 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build wasm32 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
This commit is contained in:
parent
437afebf5c
commit
cb23193f74
17 changed files with 411 additions and 106 deletions
|
@ -28,15 +28,19 @@ use serde::Serialize;
|
|||
use url::Url;
|
||||
|
||||
pub mod prompter;
|
||||
pub mod which;
|
||||
use prompter::permission_prompt;
|
||||
pub use prompter::set_prompt_callbacks;
|
||||
pub use prompter::set_prompter;
|
||||
pub use prompter::DeniedPrompter;
|
||||
pub use prompter::GetFormattedStackFn;
|
||||
pub use prompter::PermissionPrompter;
|
||||
pub use prompter::PromptCallback;
|
||||
pub use prompter::PromptResponse;
|
||||
use prompter::PERMISSION_EMOJI;
|
||||
|
||||
use self::which::WhichSys;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum PermissionDeniedError {
|
||||
#[error("Requires {access}, {}", format_permission_error(.name))]
|
||||
|
@ -1373,14 +1377,16 @@ pub enum PathResolveError {
|
|||
impl RunQueryDescriptor {
|
||||
pub fn parse(
|
||||
requested: &str,
|
||||
sys: &impl which::WhichSys,
|
||||
) -> Result<RunQueryDescriptor, PathResolveError> {
|
||||
if is_path(requested) {
|
||||
let path = PathBuf::from(requested);
|
||||
let resolved = if path.is_absolute() {
|
||||
normalize_path(path)
|
||||
} else {
|
||||
let cwd =
|
||||
std::env::current_dir().map_err(PathResolveError::CwdResolve)?;
|
||||
let cwd = sys
|
||||
.env_current_dir()
|
||||
.map_err(PathResolveError::CwdResolve)?;
|
||||
normalize_path(cwd.join(path))
|
||||
};
|
||||
Ok(RunQueryDescriptor::Path {
|
||||
|
@ -1388,7 +1394,11 @@ impl RunQueryDescriptor {
|
|||
resolved,
|
||||
})
|
||||
} else {
|
||||
match which::which(requested) {
|
||||
let cwd = sys
|
||||
.env_current_dir()
|
||||
.map_err(PathResolveError::CwdResolve)?;
|
||||
match which::which_in(sys.clone(), requested, sys.env_var_os("PATH"), cwd)
|
||||
{
|
||||
Ok(resolved) => Ok(RunQueryDescriptor::Path {
|
||||
requested: requested.to_string(),
|
||||
resolved,
|
||||
|
@ -1542,13 +1552,19 @@ impl AllowRunDescriptor {
|
|||
pub fn parse(
|
||||
text: &str,
|
||||
cwd: &Path,
|
||||
sys: &impl WhichSys,
|
||||
) -> Result<AllowRunDescriptorParseResult, which::Error> {
|
||||
let is_path = is_path(text);
|
||||
// todo(dsherret): canonicalize in #25458
|
||||
let path = if is_path {
|
||||
resolve_from_known_cwd(Path::new(text), cwd)
|
||||
} else {
|
||||
match which::which_in(text, std::env::var_os("PATH"), cwd) {
|
||||
match which::which_in(
|
||||
sys.clone(),
|
||||
text,
|
||||
sys.env_var_os("PATH"),
|
||||
cwd.to_path_buf(),
|
||||
) {
|
||||
Ok(path) => path,
|
||||
Err(err) => match err {
|
||||
which::Error::CannotGetCurrentDirAndPathListEmpty => {
|
||||
|
@ -3879,7 +3895,8 @@ mod tests {
|
|||
&self,
|
||||
requested: &str,
|
||||
) -> Result<RunQueryDescriptor, RunDescriptorParseError> {
|
||||
RunQueryDescriptor::parse(requested).map_err(Into::into)
|
||||
RunQueryDescriptor::parse(requested, &sys_traits::impls::RealSys)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue