Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(byonm): support deno run npm:<package> when package is not in package.json #25981

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove prompt
  • Loading branch information
dsherret committed Oct 1, 2024
commit adb96d15f3a4f57f1d9da425d8fea9b74606b61b
7 changes: 0 additions & 7 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,6 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
Err(script_err) => {
if let Some(ResolvePkgFolderFromDenoReqError::Byonm(ByonmResolvePkgFolderFromDenoReqError::UnmatchedReq(req))) = script_err.downcast_ref::<ResolvePkgFolderFromDenoReqError>() {
if flags.node_modules_dir.is_none() {
let message = format!(
concat!("Need to install the following packages:\nnpm:{}\nOk to proceed?"),
req
);
if !crate::util::console::confirm(&message, true) {
deno_core::anyhow::bail!("canceled");
}
let mut flags = flags.deref().clone();
let watch = match &flags.subcommand {
DenoSubcommand::Run(run_flags) => run_flags.watch.clone(),
Expand Down
17 changes: 0 additions & 17 deletions cli/util/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,3 @@ pub fn console_size() -> Option<ConsoleSize> {
let stderr = &deno_runtime::deno_io::STDERR_HANDLE;
deno_runtime::ops::tty::console_size(stderr).ok()
}

pub fn confirm(text: &str, default: bool) -> bool {
if !std::io::stderr().is_terminal() {
return default;
}
let default_str = if default { "(y)" } else { "(n)" };
eprint!("{} {} > ", text, default_str);
let _ = std::io::stderr().flush();
let mut input = String::new();
let _ = std::io::stdin().read_line(&mut input);
let input = input.trim().to_lowercase();
if input.is_empty() {
default
} else {
input == "y" || input == "yes"
}
}