mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat(permissions): expose PermissionPrompter and set_prompter function (#26327)
when defining a custom runtime, it might be useful to define a custom prompter - for instance when you are not relying on the terminal and want a GUI prompter instead
This commit is contained in:
parent
33ceae4ce5
commit
3b62e05062
2 changed files with 6 additions and 4 deletions
|
@ -39,6 +39,8 @@ use prompter::PromptResponse;
|
|||
use prompter::PERMISSION_EMOJI;
|
||||
|
||||
pub use prompter::set_prompt_callbacks;
|
||||
pub use prompter::set_prompter;
|
||||
pub use prompter::PermissionPrompter;
|
||||
pub use prompter::PromptCallback;
|
||||
|
||||
/// Fast exit from permission check routines if this permission
|
||||
|
|
|
@ -80,6 +80,10 @@ pub fn set_prompt_callbacks(
|
|||
*MAYBE_AFTER_PROMPT_CALLBACK.lock() = Some(after_callback);
|
||||
}
|
||||
|
||||
pub fn set_prompter(prompter: Box<dyn PermissionPrompter>) {
|
||||
*PERMISSION_PROMPTER.lock() = prompter;
|
||||
}
|
||||
|
||||
pub type PromptCallback = Box<dyn FnMut() + Send + Sync>;
|
||||
|
||||
pub trait PermissionPrompter: Send + Sync {
|
||||
|
@ -476,8 +480,4 @@ pub mod tests {
|
|||
STUB_PROMPT_VALUE.store(value, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_prompter(prompter: Box<dyn PermissionPrompter>) {
|
||||
*PERMISSION_PROMPTER.lock() = prompter;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue