0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

fix(cli): fetch works in Jupyter (#20552)

An op2 needs to be overloaded by an op2, not an op1.
This commit is contained in:
Matt Mastracci 2023-09-18 09:39:39 -06:00 committed by GitHub
parent 0709c051f8
commit 701931477c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ use crate::CliFactory;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::futures::channel::mpsc;
use deno_core::op;
use deno_core::op2;
use deno_core::resolve_url_or_path;
use deno_core::serde::Deserialize;
use deno_core::serde_json;
@ -105,22 +105,25 @@ deno_core::extension!(deno_jupyter,
},
);
#[op]
#[op2(fast)]
pub fn op_print(
state: &mut OpState,
msg: String,
#[string] msg: &str,
is_err: bool,
) -> Result<(), AnyError> {
let sender = state.borrow_mut::<mpsc::UnboundedSender<server::StdioMsg>>();
if is_err {
if let Err(err) = sender.unbounded_send(server::StdioMsg::Stderr(msg)) {
if let Err(err) =
sender.unbounded_send(server::StdioMsg::Stderr(msg.into()))
{
eprintln!("Failed to send stderr message: {}", err);
}
return Ok(());
}
if let Err(err) = sender.unbounded_send(server::StdioMsg::Stdout(msg)) {
if let Err(err) = sender.unbounded_send(server::StdioMsg::Stdout(msg.into()))
{
eprintln!("Failed to send stdout message: {}", err);
}
Ok(())