mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: enable clippy::print_stdout and clippy::print_stderr (#23732)
1. Generally we should prefer to use the `log` crate. 2. I very often accidentally commit `eprintln`s. When we should use `println` or `eprintln`, it's not too bad to be a bit more verbose and ignore the lint rule.
This commit is contained in:
parent
e6dc4dfbff
commit
47f7bed677
52 changed files with 307 additions and 181 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1453,6 +1453,7 @@ dependencies = [
|
||||||
"dynasmrt",
|
"dynasmrt",
|
||||||
"libffi",
|
"libffi",
|
||||||
"libffi-sys",
|
"libffi-sys",
|
||||||
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-value",
|
"serde-value",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1557,6 +1558,7 @@ dependencies = [
|
||||||
"deno_core",
|
"deno_core",
|
||||||
"filetime",
|
"filetime",
|
||||||
"fs3",
|
"fs3",
|
||||||
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"os_pipe",
|
"os_pipe",
|
||||||
"rand",
|
"rand",
|
||||||
|
|
|
@ -39,6 +39,7 @@ macro_rules! bench_or_profile {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
pub fn run_profiles(opts: &TestOpts, tests: Vec<TestDescAndFn>) {
|
pub fn run_profiles(opts: &TestOpts, tests: Vec<TestDescAndFn>) {
|
||||||
let tests = filter_tests(opts, tests);
|
let tests = filter_tests(opts, tests);
|
||||||
// let decs = tests.iter().map(|t| t.desc.clone()).collect();
|
// let decs = tests.iter().map(|t| t.desc.clone()).collect();
|
||||||
|
|
|
@ -3889,6 +3889,7 @@ fn eval_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
// TODO(@satyarohith): remove this flag in 2.0.
|
// TODO(@satyarohith): remove this flag in 2.0.
|
||||||
let as_typescript = matches.get_flag("ts");
|
let as_typescript = matches.get_flag("ts");
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if as_typescript {
|
if as_typescript {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"⚠️ {}",
|
"⚠️ {}",
|
||||||
|
@ -4218,6 +4219,8 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
let no_run = matches.get_flag("no-run");
|
let no_run = matches.get_flag("no-run");
|
||||||
let trace_leaks =
|
let trace_leaks =
|
||||||
matches.get_flag("trace-ops") || matches.get_flag("trace-leaks");
|
matches.get_flag("trace-ops") || matches.get_flag("trace-leaks");
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if trace_leaks && matches.get_flag("trace-ops") {
|
if trace_leaks && matches.get_flag("trace-ops") {
|
||||||
// We can't change this to use the log crate because its not configured
|
// We can't change this to use the log crate because its not configured
|
||||||
// yet at this point since the flags haven't been parsed. This flag is
|
// yet at this point since the flags haven't been parsed. This flag is
|
||||||
|
@ -4267,10 +4270,17 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
// yet at this point since the flags haven't been parsed. This flag is
|
// yet at this point since the flags haven't been parsed. This flag is
|
||||||
// deprecated though so it's not worth changing the code to use the log
|
// deprecated though so it's not worth changing the code to use the log
|
||||||
// crate here and this is only done for testing anyway.
|
// crate here and this is only done for testing anyway.
|
||||||
eprintln!(
|
#[allow(clippy::print_stderr)]
|
||||||
"⚠️ {}",
|
{
|
||||||
crate::colors::yellow("The `--jobs` flag is deprecated and will be removed in Deno 2.0.\nUse the `--parallel` flag with possibly the `DENO_JOBS` environment variable instead.\nLearn more at: https://docs.deno.com/runtime/manual/basics/env_variables"),
|
eprintln!(
|
||||||
);
|
"⚠️ {}",
|
||||||
|
crate::colors::yellow(concat!(
|
||||||
|
"The `--jobs` flag is deprecated and will be removed in Deno 2.0.\n",
|
||||||
|
"Use the `--parallel` flag with possibly the `DENO_JOBS` environment variable instead.\n",
|
||||||
|
"Learn more at: https://docs.deno.com/runtime/manual/basics/env_variables"
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
if let Some(value) = matches.remove_one::<NonZeroUsize>("jobs") {
|
if let Some(value) = matches.remove_one::<NonZeroUsize>("jobs") {
|
||||||
Some(value)
|
Some(value)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -747,9 +747,12 @@ impl CliOptions {
|
||||||
format!("for: {}", insecure_allowlist.join(", "))
|
format!("for: {}", insecure_allowlist.join(", "))
|
||||||
};
|
};
|
||||||
let msg =
|
let msg =
|
||||||
format!("DANGER: TLS certificate validation is disabled {domains}");
|
format!("DANGER: TLS certificate validation is disabled {}", domains);
|
||||||
// use eprintln instead of log::warn so this always gets shown
|
#[allow(clippy::print_stderr)]
|
||||||
eprintln!("{}", colors::yellow(msg));
|
{
|
||||||
|
// use eprintln instead of log::warn so this always gets shown
|
||||||
|
eprintln!("{}", colors::yellow(msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
|
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
|
|
|
@ -739,6 +739,8 @@ async fn fetch_no_follow<'a>(
|
||||||
Ok(FetchOnceResult::Code(body, result_headers))
|
Ok(FetchOnceResult::Code(body, result_headers))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cache::GlobalHttpCache;
|
use crate::cache::GlobalHttpCache;
|
||||||
|
|
|
@ -235,6 +235,7 @@ async fn run_subcommand(flags: Flags) -> Result<i32, AnyError> {
|
||||||
handle.await?
|
handle.await?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn setup_panic_hook() {
|
fn setup_panic_hook() {
|
||||||
// This function does two things inside of the panic hook:
|
// This function does two things inside of the panic hook:
|
||||||
// - Tokio does not exit the process when a task panics, so we define a custom
|
// - Tokio does not exit the process when a task panics, so we define a custom
|
||||||
|
@ -259,6 +260,7 @@ fn setup_panic_hook() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn exit_with_message(message: &str, code: i32) -> ! {
|
fn exit_with_message(message: &str, code: i32) -> ! {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
|
@ -289,6 +291,7 @@ fn exit_for_error(error: AnyError) -> ! {
|
||||||
exit_with_message(&error_string, error_code);
|
exit_with_message(&error_string, error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
||||||
|
@ -298,6 +301,7 @@ pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
pub(crate) fn unstable_warn_cb(feature: &str, api_name: &str) {
|
pub(crate) fn unstable_warn_cb(feature: &str, api_name: &str) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"⚠️ {}",
|
"⚠️ {}",
|
||||||
|
@ -369,7 +373,9 @@ fn resolve_flags_and_init(
|
||||||
|
|
||||||
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
||||||
if flags.unstable_config.legacy_flag_enabled {
|
if flags.unstable_config.legacy_flag_enabled {
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if matches!(flags.subcommand, DenoSubcommand::Check(_)) {
|
if matches!(flags.subcommand, DenoSubcommand::Check(_)) {
|
||||||
|
// can't use log crate because that's not setup yet
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"⚠️ {}",
|
"⚠️ {}",
|
||||||
colors::yellow(
|
colors::yellow(
|
||||||
|
|
|
@ -36,6 +36,7 @@ use std::env::current_exe;
|
||||||
|
|
||||||
use crate::args::Flags;
|
use crate::args::Flags;
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
||||||
|
@ -44,6 +45,7 @@ pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||||
std::process::exit(70);
|
std::process::exit(70);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn exit_with_message(message: &str, code: i32) -> ! {
|
fn exit_with_message(message: &str, code: i32) -> ! {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
|
@ -57,7 +59,7 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
|
||||||
match result {
|
match result {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let mut error_string = format!("{error:?}");
|
let mut error_string = format!("{:?}", error);
|
||||||
|
|
||||||
if let Some(e) = error.downcast_ref::<JsError>() {
|
if let Some(e) = error.downcast_ref::<JsError>() {
|
||||||
error_string = format_js_error(e);
|
error_string = format_js_error(e);
|
||||||
|
|
|
@ -76,13 +76,13 @@ pub fn op_print(
|
||||||
|
|
||||||
if is_err {
|
if is_err {
|
||||||
if let Err(err) = sender.send(StdioMsg::Stderr(msg.into())) {
|
if let Err(err) = sender.send(StdioMsg::Stderr(msg.into())) {
|
||||||
eprintln!("Failed to send stderr message: {}", err);
|
log::error!("Failed to send stderr message: {}", err);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = sender.send(StdioMsg::Stdout(msg.into())) {
|
if let Err(err) = sender.send(StdioMsg::Stdout(msg.into())) {
|
||||||
eprintln!("Failed to send stdout message: {}", err);
|
log::error!("Failed to send stdout message: {}", err);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ impl JsonReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl BenchReporter for JsonReporter {
|
impl BenchReporter for JsonReporter {
|
||||||
fn report_group_summary(&mut self) {}
|
fn report_group_summary(&mut self) {}
|
||||||
#[cold]
|
#[cold]
|
||||||
|
@ -58,7 +59,7 @@ impl BenchReporter for JsonReporter {
|
||||||
fn report_end(&mut self, _report: &BenchReport) {
|
fn report_end(&mut self, _report: &BenchReport) {
|
||||||
match write_json_to_stdout(self) {
|
match write_json_to_stdout(self) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => println!("{e}"),
|
Err(e) => println!("{}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +119,7 @@ impl ConsoleReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl BenchReporter for ConsoleReporter {
|
impl BenchReporter for ConsoleReporter {
|
||||||
#[cold]
|
#[cold]
|
||||||
fn report_plan(&mut self, plan: &BenchPlan) {
|
fn report_plan(&mut self, plan: &BenchPlan) {
|
||||||
|
|
|
@ -125,7 +125,10 @@ async fn bundle_action(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("{}", bundle_output.code);
|
#[allow(clippy::print_stdout)]
|
||||||
|
{
|
||||||
|
println!("{}", bundle_output.code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ struct SummaryCoverageReporter {
|
||||||
file_reports: Vec<(CoverageReport, String)>,
|
file_reports: Vec<(CoverageReport, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl SummaryCoverageReporter {
|
impl SummaryCoverageReporter {
|
||||||
pub fn new() -> SummaryCoverageReporter {
|
pub fn new() -> SummaryCoverageReporter {
|
||||||
SummaryCoverageReporter {
|
SummaryCoverageReporter {
|
||||||
|
@ -166,6 +167,7 @@ impl SummaryCoverageReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl CoverageReporter for SummaryCoverageReporter {
|
impl CoverageReporter for SummaryCoverageReporter {
|
||||||
fn report(
|
fn report(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -312,6 +314,7 @@ impl DetailedCoverageReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl CoverageReporter for DetailedCoverageReporter {
|
impl CoverageReporter for DetailedCoverageReporter {
|
||||||
fn report(
|
fn report(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -416,7 +419,7 @@ impl CoverageReporter for HtmlCoverageReporter {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("HTML coverage report has been generated at {}", root_report);
|
log::info!("HTML coverage report has been generated at {}", root_report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,8 +396,8 @@ async fn format_source_files(
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _g = output_lock.lock();
|
let _g = output_lock.lock();
|
||||||
eprintln!("Error formatting: {}", file_path.to_string_lossy());
|
log::error!("Error formatting: {}", file_path.to_string_lossy());
|
||||||
eprintln!(" {e}");
|
log::error!(" {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -495,6 +495,7 @@ fn format_stdin(fmt_options: FmtOptions, ext: &str) -> Result<(), AnyError> {
|
||||||
let file_path = PathBuf::from(format!("_stdin.{ext}"));
|
let file_path = PathBuf::from(format!("_stdin.{ext}"));
|
||||||
let formatted_text = format_file(&file_path, &source, &fmt_options.options)?;
|
let formatted_text = format_file(&file_path, &source, &fmt_options.options)?;
|
||||||
if fmt_options.check {
|
if fmt_options.check {
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
if formatted_text.is_some() {
|
if formatted_text.is_some() {
|
||||||
println!("Not formatted stdin");
|
println!("Not formatted stdin");
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
fn print_cache_info(
|
fn print_cache_info(
|
||||||
factory: &CliFactory,
|
factory: &CliFactory,
|
||||||
json: bool,
|
json: bool,
|
||||||
|
|
|
@ -27,13 +27,13 @@ pub fn status() -> Result<(), AnyError> {
|
||||||
if let Some(specs) = json_output.get("kernelspecs") {
|
if let Some(specs) = json_output.get("kernelspecs") {
|
||||||
if let Some(specs_obj) = specs.as_object() {
|
if let Some(specs_obj) = specs.as_object() {
|
||||||
if specs_obj.contains_key("deno") {
|
if specs_obj.contains_key("deno") {
|
||||||
println!("✅ Deno kernel already installed");
|
log::info!("✅ Deno kernel already installed");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up");
|
log::warn!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +108,6 @@ pub fn install() -> Result<(), AnyError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = std::fs::remove_dir(temp_dir);
|
let _ = std::fs::remove_dir(temp_dir);
|
||||||
println!("✅ Deno kernelspec installed successfully.");
|
log::info!("✅ Deno kernelspec installed successfully.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl JupyterServer {
|
||||||
|
|
||||||
let handle1 = deno_core::unsync::spawn(async move {
|
let handle1 = deno_core::unsync::spawn(async move {
|
||||||
if let Err(err) = Self::handle_heartbeat(&mut heartbeat).await {
|
if let Err(err) = Self::handle_heartbeat(&mut heartbeat).await {
|
||||||
eprintln!("Heartbeat error: {}", err);
|
log::error!("Heartbeat error: {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -85,14 +85,14 @@ impl JupyterServer {
|
||||||
if let Err(err) =
|
if let Err(err) =
|
||||||
Self::handle_control(control_socket, cancel_handle).await
|
Self::handle_control(control_socket, cancel_handle).await
|
||||||
{
|
{
|
||||||
eprintln!("Control error: {}", err);
|
log::error!("Control error: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let handle3 = deno_core::unsync::spawn(async move {
|
let handle3 = deno_core::unsync::spawn(async move {
|
||||||
if let Err(err) = server.handle_shell(shell_socket).await {
|
if let Err(err) = server.handle_shell(shell_socket).await {
|
||||||
eprintln!("Shell error: {}", err);
|
log::error!("Shell error: {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ impl JupyterServer {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
eprintln!("Output {} error: {}", name, err);
|
log::error!("Output {} error: {}", name, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,10 +166,10 @@ impl JupyterServer {
|
||||||
cancel_handle.cancel();
|
cancel_handle.cancel();
|
||||||
}
|
}
|
||||||
"interrupt_request" => {
|
"interrupt_request" => {
|
||||||
eprintln!("Interrupt request currently not supported");
|
log::error!("Interrupt request currently not supported");
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!(
|
log::error!(
|
||||||
"Unrecognized control message type: {}",
|
"Unrecognized control message type: {}",
|
||||||
msg.message_type()
|
msg.message_type()
|
||||||
);
|
);
|
||||||
|
@ -307,7 +307,7 @@ impl JupyterServer {
|
||||||
// We don't handle these messages
|
// We don't handle these messages
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!("Unrecognized shell message type: {}", msg.message_type());
|
log::error!("Unrecognized shell message type: {}", msg.message_type());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,12 +386,13 @@ impl JupyterServer {
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(5)).await;
|
tokio::time::sleep(std::time::Duration::from_millis(5)).await;
|
||||||
} else if let Some(exception_details) = exception_details {
|
} else if let Some(exception_details) = exception_details {
|
||||||
// Determine the exception value and name
|
// Determine the exception value and name
|
||||||
let (name, message, stack) =
|
let (name, message, stack) = if let Some(exception) =
|
||||||
if let Some(exception) = exception_details.exception {
|
exception_details.exception
|
||||||
let result = self
|
{
|
||||||
.repl_session
|
let result = self
|
||||||
.call_function_on_args(
|
.repl_session
|
||||||
r#"
|
.call_function_on_args(
|
||||||
|
r#"
|
||||||
function(object) {
|
function(object) {
|
||||||
if (object instanceof Error) {
|
if (object instanceof Error) {
|
||||||
const name = "name" in object ? String(object.name) : "";
|
const name = "name" in object ? String(object.name) : "";
|
||||||
|
@ -404,32 +405,32 @@ impl JupyterServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#
|
"#
|
||||||
.into(),
|
.into(),
|
||||||
&[exception],
|
&[exception],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match result.result.value {
|
match result.result.value {
|
||||||
Some(serde_json::Value::String(str)) => {
|
Some(serde_json::Value::String(str)) => {
|
||||||
if let Ok(object) =
|
if let Ok(object) =
|
||||||
serde_json::from_str::<HashMap<String, String>>(&str)
|
serde_json::from_str::<HashMap<String, String>>(&str)
|
||||||
{
|
{
|
||||||
let get = |k| object.get(k).cloned().unwrap_or_default();
|
let get = |k| object.get(k).cloned().unwrap_or_default();
|
||||||
(get("name"), get("message"), get("stack"))
|
(get("name"), get("message"), get("stack"))
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Unexpected result while parsing JSON {str}");
|
log::error!("Unexpected result while parsing JSON {str}");
|
||||||
("".into(), "".into(), "".into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
eprintln!("Unexpected result while parsing exception {result:?}");
|
|
||||||
("".into(), "".into(), "".into())
|
("".into(), "".into(), "".into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
_ => {
|
||||||
eprintln!("Unexpectedly missing exception {exception_details:?}");
|
log::error!("Unexpected result while parsing exception {result:?}");
|
||||||
("".into(), "".into(), "".into())
|
("".into(), "".into(), "".into())
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::error!("Unexpectedly missing exception {exception_details:?}");
|
||||||
|
("".into(), "".into(), "".into())
|
||||||
|
};
|
||||||
|
|
||||||
let stack = if stack.is_empty() {
|
let stack = if stack.is_empty() {
|
||||||
format!(
|
format!(
|
||||||
|
@ -546,7 +547,7 @@ async fn publish_result(
|
||||||
if let Some(exception_details) = &response.exception_details {
|
if let Some(exception_details) = &response.exception_details {
|
||||||
// If the object doesn't have a Jupyter.display method or it throws an
|
// If the object doesn't have a Jupyter.display method or it throws an
|
||||||
// exception, we just ignore it and let the caller handle it.
|
// exception, we just ignore it and let the caller handle it.
|
||||||
eprintln!("Exception encountered: {}", exception_details.text);
|
log::error!("Exception encountered: {}", exception_details.text);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,7 @@ fn collect_lint_files(
|
||||||
.collect_file_patterns(files)
|
.collect_file_patterns(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
|
pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
|
||||||
let lint_rules = if maybe_rules_tags.is_none() {
|
let lint_rules = if maybe_rules_tags.is_none() {
|
||||||
rules::get_all_rules()
|
rules::get_all_rules()
|
||||||
|
@ -646,12 +647,12 @@ impl LintReporter for PrettyLintReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintln!("{}", d.display());
|
log::error!("{}", d.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
||||||
eprintln!("Error linting: {file_path}");
|
log::error!("Error linting: {file_path}");
|
||||||
eprintln!(" {err}");
|
log::error!(" {err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&mut self, check_count: usize) {
|
fn close(&mut self, check_count: usize) {
|
||||||
|
@ -694,7 +695,7 @@ impl LintReporter for CompactLintReporter {
|
||||||
match d.range() {
|
match d.range() {
|
||||||
Some((text_info, range)) => {
|
Some((text_info, range)) => {
|
||||||
let line_and_column = text_info.line_and_column_display(range.start);
|
let line_and_column = text_info.line_and_column_display(range.start);
|
||||||
eprintln!(
|
log::error!(
|
||||||
"{}: line {}, col {} - {} ({})",
|
"{}: line {}, col {} - {} ({})",
|
||||||
d.specifier(),
|
d.specifier(),
|
||||||
line_and_column.line_number,
|
line_and_column.line_number,
|
||||||
|
@ -704,14 +705,14 @@ impl LintReporter for CompactLintReporter {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
eprintln!("{}: {} ({})", d.specifier(), d.message(), d.code())
|
log::error!("{}: {} ({})", d.specifier(), d.message(), d.code())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
||||||
eprintln!("Error linting: {file_path}");
|
log::error!("Error linting: {file_path}");
|
||||||
eprintln!(" {err}");
|
log::error!(" {err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&mut self, check_count: usize) {
|
fn close(&mut self, check_count: usize) {
|
||||||
|
@ -812,7 +813,10 @@ impl LintReporter for JsonLintReporter {
|
||||||
fn close(&mut self, _check_count: usize) {
|
fn close(&mut self, _check_count: usize) {
|
||||||
sort_diagnostics(&mut self.diagnostics);
|
sort_diagnostics(&mut self.diagnostics);
|
||||||
let json = serde_json::to_string_pretty(&self);
|
let json = serde_json::to_string_pretty(&self);
|
||||||
println!("{}", json.unwrap());
|
#[allow(clippy::print_stdout)]
|
||||||
|
{
|
||||||
|
println!("{}", json.unwrap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,11 @@ impl PublishDiagnosticsCollector {
|
||||||
diagnostics.sort_by_cached_key(|d| d.sorting_key());
|
diagnostics.sort_by_cached_key(|d| d.sorting_key());
|
||||||
|
|
||||||
for diagnostic in diagnostics {
|
for diagnostic in diagnostics {
|
||||||
eprint!("{}", diagnostic.display());
|
// todo(https://github.com/denoland/deno_ast/issues/245): use log crate here
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
|
{
|
||||||
|
eprint!("{}", diagnostic.display());
|
||||||
|
}
|
||||||
if matches!(diagnostic.level(), DiagnosticLevel::Error) {
|
if matches!(diagnostic.level(), DiagnosticLevel::Error) {
|
||||||
errors += 1;
|
errors += 1;
|
||||||
}
|
}
|
||||||
|
@ -48,18 +52,18 @@ impl PublishDiagnosticsCollector {
|
||||||
}
|
}
|
||||||
if errors > 0 {
|
if errors > 0 {
|
||||||
if has_slow_types_errors {
|
if has_slow_types_errors {
|
||||||
eprintln!(
|
log::error!(
|
||||||
"This package contains errors for slow types. Fixing these errors will:\n"
|
"This package contains errors for slow types. Fixing these errors will:\n"
|
||||||
);
|
);
|
||||||
eprintln!(
|
log::error!(
|
||||||
" 1. Significantly improve your package users' type checking performance."
|
" 1. Significantly improve your package users' type checking performance."
|
||||||
);
|
);
|
||||||
eprintln!(" 2. Improve the automatic documentation generation.");
|
log::error!(" 2. Improve the automatic documentation generation.");
|
||||||
eprintln!(" 3. Enable automatic .d.ts generation for Node.js.");
|
log::error!(" 3. Enable automatic .d.ts generation for Node.js.");
|
||||||
eprintln!(
|
log::error!(
|
||||||
"\nDon't want to bother? You can choose to skip this step by"
|
"\nDon't want to bother? You can choose to skip this step by"
|
||||||
);
|
);
|
||||||
eprintln!("providing the --allow-slow-types flag.\n");
|
log::error!("providing the --allow-slow-types flag.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(anyhow!(
|
Err(anyhow!(
|
||||||
|
|
|
@ -72,9 +72,10 @@ use super::check::TypeChecker;
|
||||||
use self::paths::CollectedPublishPath;
|
use self::paths::CollectedPublishPath;
|
||||||
use self::tar::PublishableTarball;
|
use self::tar::PublishableTarball;
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn ring_bell() {
|
fn ring_bell() {
|
||||||
// ASCII code for the bell character.
|
// ASCII code for the bell character.
|
||||||
print!("\x07");
|
eprint!("\x07");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreparedPublishPackage {
|
struct PreparedPublishPackage {
|
||||||
|
@ -291,18 +292,19 @@ async fn get_auth_headers(
|
||||||
.context("Failed to create interactive authorization")?;
|
.context("Failed to create interactive authorization")?;
|
||||||
|
|
||||||
let auth_url = format!("{}?code={}", auth.verification_url, auth.code);
|
let auth_url = format!("{}?code={}", auth.verification_url, auth.code);
|
||||||
print!(
|
let pkgs_text = if packages.len() > 1 {
|
||||||
"Visit {} to authorize publishing of",
|
format!("{} packages", packages.len())
|
||||||
colors::cyan(&auth_url)
|
|
||||||
);
|
|
||||||
if packages.len() > 1 {
|
|
||||||
println!(" {} packages", packages.len());
|
|
||||||
} else {
|
} else {
|
||||||
println!(" @{}/{}", packages[0].scope, packages[0].package);
|
format!("@{}/{}", packages[0].scope, packages[0].package)
|
||||||
}
|
};
|
||||||
|
log::warn!(
|
||||||
|
"Visit {} to authorize publishing of {}",
|
||||||
|
colors::cyan(&auth_url),
|
||||||
|
pkgs_text,
|
||||||
|
);
|
||||||
|
|
||||||
ring_bell();
|
ring_bell();
|
||||||
println!("{}", colors::gray("Waiting..."));
|
log::info!("{}", colors::gray("Waiting..."));
|
||||||
let _ = open::that_detached(&auth_url);
|
let _ = open::that_detached(&auth_url);
|
||||||
|
|
||||||
let interval = std::time::Duration::from_secs(auth.poll_interval);
|
let interval = std::time::Duration::from_secs(auth.poll_interval);
|
||||||
|
@ -323,7 +325,7 @@ async fn get_auth_headers(
|
||||||
.await;
|
.await;
|
||||||
match res {
|
match res {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
println!(
|
log::info!(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
colors::green("Authorization successful."),
|
colors::green("Authorization successful."),
|
||||||
colors::gray("Authenticated as"),
|
colors::gray("Authenticated as"),
|
||||||
|
@ -490,13 +492,13 @@ async fn ensure_scopes_and_packages_exist(
|
||||||
};
|
};
|
||||||
|
|
||||||
ring_bell();
|
ring_bell();
|
||||||
println!(
|
log::warn!(
|
||||||
"'@{}/{}' doesn't exist yet. Visit {} to create the package",
|
"'@{}/{}' doesn't exist yet. Visit {} to create the package",
|
||||||
&package.scope,
|
&package.scope,
|
||||||
&package.package,
|
&package.package,
|
||||||
colors::cyan_with_underline(&create_package_url)
|
colors::cyan_with_underline(&create_package_url)
|
||||||
);
|
);
|
||||||
println!("{}", colors::gray("Waiting..."));
|
log::warn!("{}", colors::gray("Waiting..."));
|
||||||
let _ = open::that_detached(&create_package_url);
|
let _ = open::that_detached(&create_package_url);
|
||||||
|
|
||||||
let package_api_url = api::get_package_api_url(
|
let package_api_url = api::get_package_api_url(
|
||||||
|
@ -510,7 +512,7 @@ async fn ensure_scopes_and_packages_exist(
|
||||||
let response = client.get(&package_api_url).send().await?;
|
let response = client.get(&package_api_url).send().await?;
|
||||||
if response.status() == 200 {
|
if response.status() == 200 {
|
||||||
let name = format!("@{}/{}", package.scope, package.package);
|
let name = format!("@{}/{}", package.scope, package.package);
|
||||||
println!("Package {} created", colors::green(name));
|
log::info!("Package {} created", colors::green(name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,7 +617,7 @@ async fn publish_package(
|
||||||
provenance: bool,
|
provenance: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let client = http_client.client()?;
|
let client = http_client.client()?;
|
||||||
println!(
|
log::info!(
|
||||||
"{} @{}/{}@{} ...",
|
"{} @{}/{}@{} ...",
|
||||||
colors::intense_blue("Publishing"),
|
colors::intense_blue("Publishing"),
|
||||||
package.scope,
|
package.scope,
|
||||||
|
@ -649,7 +651,7 @@ async fn publish_package(
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if task.status == "success" {
|
if task.status == "success" {
|
||||||
println!(
|
log::info!(
|
||||||
"{} @{}/{}@{}",
|
"{} @{}/{}@{}",
|
||||||
colors::yellow("Warning: Skipping, already published"),
|
colors::yellow("Warning: Skipping, already published"),
|
||||||
package.scope,
|
package.scope,
|
||||||
|
@ -658,7 +660,7 @@ async fn publish_package(
|
||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
println!(
|
log::info!(
|
||||||
"{} @{}/{}@{}",
|
"{} @{}/{}@{}",
|
||||||
colors::yellow("Already uploaded, waiting for publishing"),
|
colors::yellow("Already uploaded, waiting for publishing"),
|
||||||
package.scope,
|
package.scope,
|
||||||
|
@ -711,7 +713,7 @@ async fn publish_package(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(
|
log::info!(
|
||||||
"{} @{}/{}@{}",
|
"{} @{}/{}@{}",
|
||||||
colors::green("Successfully published"),
|
colors::green("Successfully published"),
|
||||||
package.scope,
|
package.scope,
|
||||||
|
@ -748,7 +750,7 @@ async fn publish_package(
|
||||||
let bundle = provenance::generate_provenance(subject).await?;
|
let bundle = provenance::generate_provenance(subject).await?;
|
||||||
|
|
||||||
let tlog_entry = &bundle.verification_material.tlog_entries[0];
|
let tlog_entry = &bundle.verification_material.tlog_entries[0];
|
||||||
println!("{}",
|
log::info!("{}",
|
||||||
colors::green(format!(
|
colors::green(format!(
|
||||||
"Provenance transparency log available at https://search.sigstore.dev/?logIndex={}",
|
"Provenance transparency log available at https://search.sigstore.dev/?logIndex={}",
|
||||||
tlog_entry.log_index
|
tlog_entry.log_index
|
||||||
|
@ -768,7 +770,7 @@ async fn publish_package(
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(
|
log::info!(
|
||||||
"{}",
|
"{}",
|
||||||
colors::gray(format!(
|
colors::gray(format!(
|
||||||
"Visit {}@{}/{}@{} for details",
|
"Visit {}@{}/{}@{} for details",
|
||||||
|
@ -798,7 +800,7 @@ async fn prepare_packages_for_publishing(
|
||||||
let cli_options = cli_factory.cli_options();
|
let cli_options = cli_factory.cli_options();
|
||||||
|
|
||||||
if members.len() > 1 {
|
if members.len() > 1 {
|
||||||
println!("Publishing a workspace...");
|
log::info!("Publishing a workspace...");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the module graph
|
// create the module graph
|
||||||
|
|
|
@ -490,7 +490,7 @@ impl ReplEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.errored_on_history_save.store(true, Relaxed);
|
self.errored_on_history_save.store(true, Relaxed);
|
||||||
eprintln!("Unable to save history file: {e}");
|
log::warn!("Unable to save history file: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct Repl {
|
||||||
message_handler: RustylineSyncMessageHandler,
|
message_handler: RustylineSyncMessageHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl Repl {
|
impl Repl {
|
||||||
async fn run(&mut self) -> Result<(), AnyError> {
|
async fn run(&mut self) -> Result<(), AnyError> {
|
||||||
loop {
|
loop {
|
||||||
|
@ -61,7 +62,7 @@ impl Repl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{output}");
|
println!("{}", output);
|
||||||
}
|
}
|
||||||
Err(ReadlineError::Interrupted) => {
|
Err(ReadlineError::Interrupted) => {
|
||||||
if self.editor.should_exit_on_interrupt() {
|
if self.editor.should_exit_on_interrupt() {
|
||||||
|
@ -75,7 +76,7 @@ impl Repl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("Error: {err:?}");
|
println!("Error: {:?}", err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +86,7 @@ impl Repl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
async fn read_line_and_poll(
|
async fn read_line_and_poll(
|
||||||
repl_session: &mut ReplSession,
|
repl_session: &mut ReplSession,
|
||||||
message_handler: &mut RustylineSyncMessageHandler,
|
message_handler: &mut RustylineSyncMessageHandler,
|
||||||
|
@ -152,6 +154,7 @@ async fn read_eval_file(
|
||||||
Ok(file.into_text_decoded()?.source)
|
Ok(file.into_text_decoded()?.source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
|
pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
|
||||||
let factory = CliFactory::from_flags(flags)?;
|
let factory = CliFactory::from_flags(flags)?;
|
||||||
let cli_options = factory.cli_options();
|
let cli_options = factory.cli_options();
|
||||||
|
|
|
@ -44,7 +44,11 @@ pub async fn execute_script(
|
||||||
let task_name = match &task_flags.task {
|
let task_name = match &task_flags.task {
|
||||||
Some(task) => task,
|
Some(task) => task,
|
||||||
None => {
|
None => {
|
||||||
print_available_tasks(&tasks_config, &package_json_scripts);
|
print_available_tasks(
|
||||||
|
&mut std::io::stdout(),
|
||||||
|
&tasks_config,
|
||||||
|
&package_json_scripts,
|
||||||
|
)?;
|
||||||
return Ok(1);
|
return Ok(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -145,8 +149,14 @@ pub async fn execute_script(
|
||||||
|
|
||||||
Ok(0)
|
Ok(0)
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Task not found: {task_name}");
|
log::error!("Task not found: {task_name}");
|
||||||
print_available_tasks(&tasks_config, &package_json_scripts);
|
if log::log_enabled!(log::Level::Error) {
|
||||||
|
print_available_tasks(
|
||||||
|
&mut std::io::stderr(),
|
||||||
|
&tasks_config,
|
||||||
|
&package_json_scripts,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
Ok(1)
|
Ok(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,48 +249,58 @@ fn collect_env_vars() -> HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_available_tasks(
|
fn print_available_tasks(
|
||||||
// order can be important, so these use an index map
|
writer: &mut dyn std::io::Write,
|
||||||
tasks_config: &IndexMap<String, deno_config::Task>,
|
tasks_config: &IndexMap<String, deno_config::Task>,
|
||||||
package_json_scripts: &IndexMap<String, String>,
|
package_json_scripts: &IndexMap<String, String>,
|
||||||
) {
|
) -> Result<(), std::io::Error> {
|
||||||
eprintln!("{}", colors::green("Available tasks:"));
|
writeln!(writer, "{}", colors::green("Available tasks:"))?;
|
||||||
|
|
||||||
let mut had_task = false;
|
if tasks_config.is_empty() && package_json_scripts.is_empty() {
|
||||||
for (is_deno, (key, task)) in tasks_config
|
writeln!(
|
||||||
.iter()
|
writer,
|
||||||
.map(|(k, t)| (true, (k, t.clone())))
|
" {}",
|
||||||
.chain(
|
colors::red("No tasks found in configuration file")
|
||||||
package_json_scripts
|
)?;
|
||||||
.iter()
|
} else {
|
||||||
.filter(|(key, _)| !tasks_config.contains_key(*key))
|
for (is_deno, (key, task)) in tasks_config
|
||||||
.map(|(k, v)| (false, (k, deno_config::Task::Definition(v.clone())))),
|
.iter()
|
||||||
)
|
.map(|(k, t)| (true, (k, t.clone())))
|
||||||
{
|
.chain(
|
||||||
eprintln!(
|
package_json_scripts
|
||||||
"- {}{}",
|
.iter()
|
||||||
colors::cyan(key),
|
.filter(|(key, _)| !tasks_config.contains_key(*key))
|
||||||
if is_deno {
|
.map(|(k, v)| (false, (k, deno_config::Task::Definition(v.clone())))),
|
||||||
"".to_string()
|
)
|
||||||
} else {
|
{
|
||||||
format!(" {}", colors::italic_gray("(package.json)"))
|
writeln!(
|
||||||
}
|
writer,
|
||||||
);
|
"- {}{}",
|
||||||
let definition = match &task {
|
colors::cyan(key),
|
||||||
deno_config::Task::Definition(definition) => definition,
|
if is_deno {
|
||||||
deno_config::Task::Commented { definition, .. } => definition,
|
"".to_string()
|
||||||
};
|
} else {
|
||||||
if let deno_config::Task::Commented { comments, .. } = &task {
|
format!(" {}", colors::italic_gray("(package.json)"))
|
||||||
let slash_slash = colors::italic_gray("//");
|
}
|
||||||
for comment in comments {
|
)?;
|
||||||
eprintln!(" {slash_slash} {}", colors::italic_gray(comment));
|
let definition = match &task {
|
||||||
|
deno_config::Task::Definition(definition) => definition,
|
||||||
|
deno_config::Task::Commented { definition, .. } => definition,
|
||||||
|
};
|
||||||
|
if let deno_config::Task::Commented { comments, .. } = &task {
|
||||||
|
let slash_slash = colors::italic_gray("//");
|
||||||
|
for comment in comments {
|
||||||
|
writeln!(
|
||||||
|
writer,
|
||||||
|
" {slash_slash} {}",
|
||||||
|
colors::italic_gray(comment)
|
||||||
|
)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
writeln!(writer, " {definition}")?;
|
||||||
}
|
}
|
||||||
eprintln!(" {definition}");
|
|
||||||
had_task = true;
|
|
||||||
}
|
|
||||||
if !had_task {
|
|
||||||
eprintln!(" {}", colors::red("No tasks found in configuration file"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NpxCommand;
|
struct NpxCommand;
|
||||||
|
|
|
@ -442,6 +442,8 @@ impl TestEventSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1518,6 +1518,8 @@ pub async fn report_tests(
|
||||||
&tests,
|
&tests,
|
||||||
&test_steps,
|
&test_steps,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if let Err(err) = reporter.flush_report(&elapsed, &tests, &test_steps) {
|
if let Err(err) = reporter.flush_report(&elapsed, &tests, &test_steps) {
|
||||||
eprint!("Test reporter failed to flush: {}", err)
|
eprint!("Test reporter failed to flush: {}", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub struct DotTestReporter {
|
||||||
summary: TestSummary,
|
summary: TestSummary,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl DotTestReporter {
|
impl DotTestReporter {
|
||||||
pub fn new(cwd: Url) -> DotTestReporter {
|
pub fn new(cwd: Url) -> DotTestReporter {
|
||||||
let console_width = if let Some(size) = crate::util::console::console_size()
|
let console_width = if let Some(size) = crate::util::console::console_size()
|
||||||
|
@ -80,6 +81,7 @@ fn fmt_cancelled() -> String {
|
||||||
colors::gray("!").to_string()
|
colors::gray("!").to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl TestReporter for DotTestReporter {
|
impl TestReporter for DotTestReporter {
|
||||||
fn report_register(&mut self, _description: &TestDescription) {}
|
fn report_register(&mut self, _description: &TestDescription) {}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub struct TapTestReporter {
|
||||||
step_results: HashMap<usize, Vec<(TestStepDescription, TestStepResult)>>,
|
step_results: HashMap<usize, Vec<(TestStepDescription, TestStepResult)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl TapTestReporter {
|
impl TapTestReporter {
|
||||||
pub fn new(cwd: Url, is_concurrent: bool) -> TapTestReporter {
|
pub fn new(cwd: Url, is_concurrent: bool) -> TapTestReporter {
|
||||||
TapTestReporter {
|
TapTestReporter {
|
||||||
|
@ -113,6 +114,7 @@ impl TapTestReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
impl TestReporter for TapTestReporter {
|
impl TestReporter for TapTestReporter {
|
||||||
fn report_register(&mut self, _description: &TestDescription) {}
|
fn report_register(&mut self, _description: &TestDescription) {}
|
||||||
|
|
||||||
|
|
|
@ -274,23 +274,17 @@ pub fn check_for_upgrades(
|
||||||
if let Some(upgrade_version) = update_checker.should_prompt() {
|
if let Some(upgrade_version) = update_checker.should_prompt() {
|
||||||
if log::log_enabled!(log::Level::Info) && std::io::stderr().is_terminal() {
|
if log::log_enabled!(log::Level::Info) && std::io::stderr().is_terminal() {
|
||||||
if version::is_canary() {
|
if version::is_canary() {
|
||||||
eprint!(
|
log::info!(
|
||||||
"{} ",
|
"{} {}",
|
||||||
colors::green("A new canary release of Deno is available.")
|
colors::green("A new canary release of Deno is available."),
|
||||||
);
|
|
||||||
eprintln!(
|
|
||||||
"{}",
|
|
||||||
colors::italic_gray("Run `deno upgrade --canary` to install it.")
|
colors::italic_gray("Run `deno upgrade --canary` to install it.")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
eprint!(
|
log::info!(
|
||||||
"{} {} → {} ",
|
"{} {} → {} {}",
|
||||||
colors::green("A new release of Deno is available:"),
|
colors::green("A new release of Deno is available:"),
|
||||||
colors::cyan(version::deno()),
|
colors::cyan(version::deno()),
|
||||||
colors::cyan(&upgrade_version)
|
colors::cyan(&upgrade_version),
|
||||||
);
|
|
||||||
eprintln!(
|
|
||||||
"{}",
|
|
||||||
colors::italic_gray("Run `deno upgrade` to install it.")
|
colors::italic_gray("Run `deno upgrade` to install it.")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ impl DebouncedReceiver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
async fn error_handler<F>(watch_future: F) -> bool
|
async fn error_handler<F>(watch_future: F) -> bool
|
||||||
where
|
where
|
||||||
F: Future<Output = Result<(), AnyError>>,
|
F: Future<Output = Result<(), AnyError>>,
|
||||||
|
@ -132,8 +133,9 @@ fn create_print_after_restart_fn(
|
||||||
clear_screen: bool,
|
clear_screen: bool,
|
||||||
) -> impl Fn() {
|
) -> impl Fn() {
|
||||||
move || {
|
move || {
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if clear_screen && std::io::stderr().is_terminal() {
|
if clear_screen && std::io::stderr().is_terminal() {
|
||||||
eprint!("{CLEAR_SCREEN}");
|
eprint!("{}", CLEAR_SCREEN);
|
||||||
}
|
}
|
||||||
info!(
|
info!(
|
||||||
"{} File change detected! Restarting!",
|
"{} File change detected! Restarting!",
|
||||||
|
|
|
@ -43,6 +43,8 @@ pub fn init_v8_flags(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if !unrecognized_v8_flags.is_empty() {
|
if !unrecognized_v8_flags.is_empty() {
|
||||||
for f in unrecognized_v8_flags {
|
for f in unrecognized_v8_flags {
|
||||||
eprintln!("error: V8 did not recognize flag '{f}'");
|
eprintln!("error: V8 did not recognize flag '{f}'");
|
||||||
|
|
|
@ -868,6 +868,8 @@ fn create_web_worker_callback(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -19,6 +19,7 @@ dlopen2.workspace = true
|
||||||
dynasmrt = "1.2.3"
|
dynasmrt = "1.2.3"
|
||||||
libffi = "=3.2.0"
|
libffi = "=3.2.0"
|
||||||
libffi-sys = "=2.3.0"
|
libffi-sys = "=2.3.0"
|
||||||
|
log.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde-value = "0.7"
|
serde-value = "0.7"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
|
@ -176,7 +176,7 @@ unsafe extern "C" fn deno_ffi_callback(
|
||||||
let tc_scope = &mut TryCatch::new(scope);
|
let tc_scope = &mut TryCatch::new(scope);
|
||||||
args.run(tc_scope);
|
args.run(tc_scope);
|
||||||
if tc_scope.exception().is_some() {
|
if tc_scope.exception().is_some() {
|
||||||
eprintln!("Illegal unhandled exception in nonblocking callback.");
|
log::error!("Illegal unhandled exception in nonblocking callback.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,6 +625,7 @@ impl PollFrame for BrotliResponseStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -18,6 +18,7 @@ async-trait.workspace = true
|
||||||
deno_core.workspace = true
|
deno_core.workspace = true
|
||||||
filetime.workspace = true
|
filetime.workspace = true
|
||||||
fs3.workspace = true
|
fs3.workspace = true
|
||||||
|
log.workspace = true
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn create_named_pipe_inner() -> io::Result<(RawHandle, RawHandle)> {
|
||||||
// This should not happen, so we would like to get some better diagnostics here.
|
// This should not happen, so we would like to get some better diagnostics here.
|
||||||
// SAFETY: Printing last error for diagnostics
|
// SAFETY: Printing last error for diagnostics
|
||||||
unsafe {
|
unsafe {
|
||||||
eprintln!(
|
log::error!(
|
||||||
"*** Unexpected server pipe failure '{pipe_name:?}': {:x}",
|
"*** Unexpected server pipe failure '{pipe_name:?}': {:x}",
|
||||||
GetLastError()
|
GetLastError()
|
||||||
);
|
);
|
||||||
|
@ -99,7 +99,7 @@ fn create_named_pipe_inner() -> io::Result<(RawHandle, RawHandle)> {
|
||||||
// SAFETY: Getting last error for diagnostics
|
// SAFETY: Getting last error for diagnostics
|
||||||
let error = unsafe { GetLastError() };
|
let error = unsafe { GetLastError() };
|
||||||
// This should not happen, so we would like to get some better diagnostics here.
|
// This should not happen, so we would like to get some better diagnostics here.
|
||||||
eprintln!(
|
log::error!(
|
||||||
"*** Unexpected client pipe failure '{pipe_name:?}': {:x}",
|
"*** Unexpected client pipe failure '{pipe_name:?}': {:x}",
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ fn handle_ws_request(
|
||||||
let websocket = match fut.await {
|
let websocket = match fut.await {
|
||||||
Ok(w) => w,
|
Ok(w) => w,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!(
|
log::error!(
|
||||||
"Inspector server failed to upgrade to WS connection: {:?}",
|
"Inspector server failed to upgrade to WS connection: {:?}",
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
|
@ -194,7 +194,7 @@ fn handle_ws_request(
|
||||||
rx: inbound_rx,
|
rx: inbound_rx,
|
||||||
};
|
};
|
||||||
|
|
||||||
eprintln!("Debugger session started.");
|
log::info!("Debugger session started.");
|
||||||
let _ = new_session_tx.unbounded_send(inspector_session_proxy);
|
let _ = new_session_tx.unbounded_send(inspector_session_proxy);
|
||||||
pump_websocket_messages(websocket, inbound_tx, outbound_rx).await;
|
pump_websocket_messages(websocket, inbound_tx, outbound_rx).await;
|
||||||
});
|
});
|
||||||
|
@ -244,13 +244,13 @@ async fn server(
|
||||||
let inspector_map = Rc::clone(&inspector_map_);
|
let inspector_map = Rc::clone(&inspector_map_);
|
||||||
let mut register_inspector_handler = pin!(register_inspector_rx
|
let mut register_inspector_handler = pin!(register_inspector_rx
|
||||||
.map(|info| {
|
.map(|info| {
|
||||||
eprintln!(
|
log::info!(
|
||||||
"Debugger listening on {}",
|
"Debugger listening on {}",
|
||||||
info.get_websocket_debugger_url(&info.host.to_string())
|
info.get_websocket_debugger_url(&info.host.to_string())
|
||||||
);
|
);
|
||||||
eprintln!("Visit chrome://inspect to connect to the debugger.");
|
log::info!("Visit chrome://inspect to connect to the debugger.");
|
||||||
if info.wait_for_session {
|
if info.wait_for_session {
|
||||||
eprintln!("Deno is waiting for debugger to connect.");
|
log::info!("Deno is waiting for debugger to connect.");
|
||||||
}
|
}
|
||||||
if inspector_map.borrow_mut().insert(info.uuid, info).is_some() {
|
if inspector_map.borrow_mut().insert(info.uuid, info).is_some() {
|
||||||
panic!("Inspector UUID already in map");
|
panic!("Inspector UUID already in map");
|
||||||
|
@ -277,7 +277,7 @@ async fn server(
|
||||||
let listener = match TcpListener::from_std(listener) {
|
let listener = match TcpListener::from_std(listener) {
|
||||||
Ok(l) => l,
|
Ok(l) => l,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Cannot start inspector server: {:?}", err);
|
log::error!("Cannot start inspector server: {:?}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ async fn server(
|
||||||
match accept_result {
|
match accept_result {
|
||||||
Ok((s, _)) => s,
|
Ok((s, _)) => s,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Failed to accept inspector connection: {:?}", err);
|
log::error!("Failed to accept inspector connection: {:?}", err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ async fn server(
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
result = conn.as_mut() => {
|
result = conn.as_mut() => {
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
eprintln!("Failed to serve connection: {:?}", err);
|
log::error!("Failed to serve connection: {:?}", err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ = &mut shutdown_rx => {
|
_ = &mut shutdown_rx => {
|
||||||
|
@ -409,7 +409,7 @@ async fn pump_websocket_messages(
|
||||||
OpCode::Close => {
|
OpCode::Close => {
|
||||||
// Users don't care if there was an error coming from debugger,
|
// Users don't care if there was an error coming from debugger,
|
||||||
// just about the fact that debugger did disconnect.
|
// just about the fact that debugger did disconnect.
|
||||||
eprintln!("Debugger session ended");
|
log::info!("Debugger session ended");
|
||||||
break 'pump;
|
break 'pump;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -280,6 +280,7 @@ impl PermissionPrompter for TtyPrompter {
|
||||||
return PromptResponse::Deny;
|
return PromptResponse::Deny;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if message.len() > MAX_PERMISSION_PROMPT_LENGTH {
|
if message.len() > MAX_PERMISSION_PROMPT_LENGTH {
|
||||||
eprintln!("❌ Permission prompt length ({} bytes) was larger than the configured maximum length ({} bytes): denying request.", message.len(), MAX_PERMISSION_PROMPT_LENGTH);
|
eprintln!("❌ Permission prompt length ({} bytes) was larger than the configured maximum length ({} bytes): denying request.", message.len(), MAX_PERMISSION_PROMPT_LENGTH);
|
||||||
eprintln!("❌ WARNING: This may indicate that code is trying to bypass or hide permission check requests.");
|
eprintln!("❌ WARNING: This may indicate that code is trying to bypass or hide permission check requests.");
|
||||||
|
@ -298,6 +299,7 @@ impl PermissionPrompter for TtyPrompter {
|
||||||
|
|
||||||
// For security reasons we must consume everything in stdin so that previously
|
// For security reasons we must consume everything in stdin so that previously
|
||||||
// buffered data cannot affect the prompt.
|
// buffered data cannot affect the prompt.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
||||||
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
||||||
return PromptResponse::Deny; // don't grant permission if this fails
|
return PromptResponse::Deny; // don't grant permission if this fails
|
||||||
|
@ -336,6 +338,7 @@ impl PermissionPrompter for TtyPrompter {
|
||||||
// Clear stdin each time we loop around in case the user accidentally pasted
|
// Clear stdin each time we loop around in case the user accidentally pasted
|
||||||
// multiple lines or otherwise did something silly to generate a torrent of
|
// multiple lines or otherwise did something silly to generate a torrent of
|
||||||
// input. This doesn't work on Windows because `clear_stdin` has other side-effects.
|
// input. This doesn't work on Windows because `clear_stdin` has other side-effects.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
||||||
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
||||||
|
|
|
@ -296,6 +296,7 @@ pub fn create_runtime_snapshot(
|
||||||
let mut snapshot = std::fs::File::create(snapshot_path).unwrap();
|
let mut snapshot = std::fs::File::create(snapshot_path).unwrap();
|
||||||
snapshot.write_all(&output.output).unwrap();
|
snapshot.write_all(&output.output).unwrap();
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
for path in output.files_loaded_during_snapshot {
|
for path in output.files_loaded_during_snapshot {
|
||||||
println!("cargo:rerun-if-changed={}", path.display());
|
println!("cargo:rerun-if-changed={}", path.display());
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,9 @@ where
|
||||||
let handle = tokio::runtime::Handle::current();
|
let handle = tokio::runtime::Handle::current();
|
||||||
let runtime_monitor = RuntimeMonitor::new(&handle);
|
let runtime_monitor = RuntimeMonitor::new(&handle);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
for interval in runtime_monitor.intervals() {
|
for interval in runtime_monitor.intervals() {
|
||||||
println!("{:#?}", interval);
|
eprintln!("{:#?}", interval);
|
||||||
// wait 500ms
|
// wait 500ms
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(
|
tokio::time::sleep(std::time::Duration::from_millis(
|
||||||
metrics_interval,
|
metrics_interval,
|
||||||
|
|
|
@ -805,6 +805,7 @@ impl WebWorker {
|
||||||
|
|
||||||
// TODO(mmastrac): we don't want to test this w/classic workers because
|
// TODO(mmastrac): we don't want to test this w/classic workers because
|
||||||
// WPT triggers a failure here. This is only exposed via --enable-testing-features-do-not-use.
|
// WPT triggers a failure here. This is only exposed via --enable-testing-features-do-not-use.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
if self.worker_type == WebWorkerType::Module {
|
if self.worker_type == WebWorkerType::Module {
|
||||||
panic!(
|
panic!(
|
||||||
"coding error: either js is polling or the worker is terminated"
|
"coding error: either js is polling or the worker is terminated"
|
||||||
|
@ -878,6 +879,7 @@ impl WebWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn print_worker_error(
|
fn print_worker_error(
|
||||||
error: &AnyError,
|
error: &AnyError,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|
|
@ -279,6 +279,7 @@ pub fn create_op_metrics(
|
||||||
max_len.set(max_len.get().max(decl.name.len()));
|
max_len.set(max_len.get().max(decl.name.len()));
|
||||||
let max_len = max_len.clone();
|
let max_len = max_len.clone();
|
||||||
Some(Rc::new(
|
Some(Rc::new(
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
move |op: &deno_core::_ops::OpCtx, event, source| {
|
move |op: &deno_core::_ops::OpCtx, event, source| {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"[{: >10.3}] {name:max_len$}: {event:?} {source:?}",
|
"[{: >10.3}] {name:max_len$}: {event:?} {source:?}",
|
||||||
|
@ -518,7 +519,7 @@ impl MainWorker {
|
||||||
if !has_notified_of_inspector_disconnect
|
if !has_notified_of_inspector_disconnect
|
||||||
.swap(true, std::sync::atomic::Ordering::SeqCst)
|
.swap(true, std::sync::atomic::Ordering::SeqCst)
|
||||||
{
|
{
|
||||||
println!("Program finished. Waiting for inspector to disconnect to exit the process...");
|
log::info!("Program finished. Waiting for inspector to disconnect to exit the process...");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
#![allow(clippy::undocumented_unsafe_blocks)]
|
#![allow(clippy::undocumented_unsafe_blocks)]
|
||||||
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use test_util::deno_cmd;
|
use test_util::deno_cmd;
|
||||||
|
|
|
@ -21,6 +21,7 @@ use test_util as util;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tokio::time::timeout;
|
use tokio::time::timeout;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use util::assert_contains;
|
||||||
use util::assert_starts_with;
|
use util::assert_starts_with;
|
||||||
use util::DenoChild;
|
use util::DenoChild;
|
||||||
use util::TestContextBuilder;
|
use util::TestContextBuilder;
|
||||||
|
@ -94,12 +95,18 @@ impl InspectorTester {
|
||||||
F: FnMut(&str) -> bool + 'static,
|
F: FnMut(&str) -> bool + 'static,
|
||||||
{
|
{
|
||||||
let stdout = child.stdout.take().unwrap();
|
let stdout = child.stdout.take().unwrap();
|
||||||
let stdout_lines =
|
let stdout_lines = std::io::BufReader::new(stdout).lines().map(|r| {
|
||||||
std::io::BufReader::new(stdout).lines().map(|r| r.unwrap());
|
let line = r.unwrap();
|
||||||
|
eprintln!("STDOUT: {}", line);
|
||||||
|
line
|
||||||
|
});
|
||||||
|
|
||||||
let stderr = child.stderr.take().unwrap();
|
let stderr = child.stderr.take().unwrap();
|
||||||
let mut stderr_lines =
|
let mut stderr_lines = std::io::BufReader::new(stderr).lines().map(|r| {
|
||||||
std::io::BufReader::new(stderr).lines().map(|r| r.unwrap());
|
let line = r.unwrap();
|
||||||
|
eprintln!("STDERR: {}", line);
|
||||||
|
line
|
||||||
|
});
|
||||||
|
|
||||||
let uri = extract_ws_url_from_stderr(&mut stderr_lines);
|
let uri = extract_ws_url_from_stderr(&mut stderr_lines);
|
||||||
|
|
||||||
|
@ -810,7 +817,6 @@ async fn inspector_break_on_first_line_in_test() {
|
||||||
let script = util::testdata_path().join("inspector/inspector_test.js");
|
let script = util::testdata_path().join("inspector/inspector_test.js");
|
||||||
let child = util::deno_cmd()
|
let child = util::deno_cmd()
|
||||||
.arg("test")
|
.arg("test")
|
||||||
.arg("--quiet")
|
|
||||||
.arg(inspect_flag_with_unique_port("--inspect-brk"))
|
.arg(inspect_flag_with_unique_port("--inspect-brk"))
|
||||||
.arg(script)
|
.arg(script)
|
||||||
.env("NO_COLOR", "1")
|
.env("NO_COLOR", "1")
|
||||||
|
@ -877,10 +883,7 @@ async fn inspector_break_on_first_line_in_test() {
|
||||||
|
|
||||||
assert_starts_with!(&tester.stdout_line(), "running 1 test from");
|
assert_starts_with!(&tester.stdout_line(), "running 1 test from");
|
||||||
let line = tester.stdout_line();
|
let line = tester.stdout_line();
|
||||||
assert!(
|
assert_contains!(line, "basic test ... ok");
|
||||||
&line.contains("basic test ... ok"),
|
|
||||||
"Missing content: {line}"
|
|
||||||
);
|
|
||||||
|
|
||||||
tester.child.kill().unwrap();
|
tester.child.kill().unwrap();
|
||||||
tester.child.wait().unwrap();
|
tester.child.wait().unwrap();
|
||||||
|
@ -907,6 +910,7 @@ async fn inspector_with_ts_files() {
|
||||||
let mut tester = InspectorTester::create(child, notification_filter).await;
|
let mut tester = InspectorTester::create(child, notification_filter).await;
|
||||||
|
|
||||||
tester.assert_stderr_for_inspect_brk();
|
tester.assert_stderr_for_inspect_brk();
|
||||||
|
assert_eq!(&tester.stderr_line(), "Debugger session started.");
|
||||||
|
|
||||||
tester
|
tester
|
||||||
.send_many(&[
|
.send_many(&[
|
||||||
|
@ -926,19 +930,19 @@ async fn inspector_with_ts_files() {
|
||||||
|
|
||||||
// receive messages with sources from this test
|
// receive messages with sources from this test
|
||||||
let script1 = tester.recv().await;
|
let script1 = tester.recv().await;
|
||||||
assert!(script1.contains("testdata/inspector/test.ts"));
|
assert_contains!(script1, "testdata/inspector/test.ts");
|
||||||
let script1_id = {
|
let script1_id = {
|
||||||
let v: serde_json::Value = serde_json::from_str(&script1).unwrap();
|
let v: serde_json::Value = serde_json::from_str(&script1).unwrap();
|
||||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||||
};
|
};
|
||||||
let script2 = tester.recv().await;
|
let script2 = tester.recv().await;
|
||||||
assert!(script2.contains("testdata/inspector/foo.ts"));
|
assert_contains!(script2, "testdata/inspector/foo.ts");
|
||||||
let script2_id = {
|
let script2_id = {
|
||||||
let v: serde_json::Value = serde_json::from_str(&script2).unwrap();
|
let v: serde_json::Value = serde_json::from_str(&script2).unwrap();
|
||||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||||
};
|
};
|
||||||
let script3 = tester.recv().await;
|
let script3 = tester.recv().await;
|
||||||
assert!(script3.contains("testdata/inspector/bar.js"));
|
assert_contains!(script3, "testdata/inspector/bar.js");
|
||||||
let script3_id = {
|
let script3_id = {
|
||||||
let v: serde_json::Value = serde_json::from_str(&script3).unwrap();
|
let v: serde_json::Value = serde_json::from_str(&script3).unwrap();
|
||||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||||
|
@ -996,10 +1000,12 @@ async fn inspector_with_ts_files() {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let line = tester.stderr_line();
|
||||||
|
assert_contains!(test_util::strip_ansi_codes(&line), "Check");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&tester.stdout_line(),
|
&tester.stderr_line(),
|
||||||
"Program finished. Waiting for inspector to disconnect to exit the process..."
|
"Program finished. Waiting for inspector to disconnect to exit the process..."
|
||||||
);
|
);
|
||||||
|
|
||||||
tester.child.kill().unwrap();
|
tester.child.kill().unwrap();
|
||||||
tester.child.wait().unwrap();
|
tester.child.wait().unwrap();
|
||||||
|
@ -1194,7 +1200,6 @@ async fn inspector_break_on_first_line_npm_esm() {
|
||||||
.new_command()
|
.new_command()
|
||||||
.args_vec([
|
.args_vec([
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
|
||||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||||
"npm:@denotest/bin/cli-esm",
|
"npm:@denotest/bin/cli-esm",
|
||||||
"this",
|
"this",
|
||||||
|
@ -1262,7 +1267,6 @@ async fn inspector_break_on_first_line_npm_cjs() {
|
||||||
.new_command()
|
.new_command()
|
||||||
.args_vec([
|
.args_vec([
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
|
||||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||||
"npm:@denotest/bin/cli-cjs",
|
"npm:@denotest/bin/cli-cjs",
|
||||||
"this",
|
"this",
|
||||||
|
@ -1331,7 +1335,6 @@ async fn inspector_error_with_npm_import() {
|
||||||
.new_command()
|
.new_command()
|
||||||
.args_vec([
|
.args_vec([
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
|
||||||
"-A",
|
"-A",
|
||||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||||
&script.to_string_lossy(),
|
&script.to_string_lossy(),
|
||||||
|
@ -1394,7 +1397,6 @@ async fn inspector_wait() {
|
||||||
.new_command()
|
.new_command()
|
||||||
.args_vec([
|
.args_vec([
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
|
||||||
"-A",
|
"-A",
|
||||||
&inspect_flag_with_unique_port("--inspect-wait"),
|
&inspect_flag_with_unique_port("--inspect-wait"),
|
||||||
&script.to_string_lossy(),
|
&script.to_string_lossy(),
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
// These files have `_tests.rs` suffix to make it easier to tell which file is
|
// These files have `_tests.rs` suffix to make it easier to tell which file is
|
||||||
// the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`)
|
// the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`)
|
||||||
// when both are open, especially for two tabs in VS Code
|
// when both are open, especially for two tabs in VS Code
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
#![allow(clippy::undocumented_unsafe_blocks)]
|
#![allow(clippy::undocumented_unsafe_blocks)]
|
||||||
|
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use test_util::deno_cmd;
|
use test_util::deno_cmd;
|
||||||
use test_util::deno_config_path;
|
use test_util::deno_config_path;
|
||||||
|
@ -80,8 +83,8 @@ fn napi_tests() {
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
eprintln!("exit code {:?}", output.status.code());
|
eprintln!("exit code {:?}", output.status.code());
|
||||||
println!("stdout {stdout}");
|
println!("stdout {}", stdout);
|
||||||
println!("stderr {stderr}");
|
println!("stderr {}", stderr);
|
||||||
}
|
}
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
}
|
}
|
||||||
|
|
5
tests/testdata/inspector/inspector_test.js
vendored
5
tests/testdata/inspector/inspector_test.js
vendored
|
@ -1,3 +1,6 @@
|
||||||
Deno.test("basic test", () => {
|
Deno.test("basic test", () => {
|
||||||
console.log("test has finished running");
|
const value = 1 + 1;
|
||||||
|
if (value !== 2) {
|
||||||
|
throw new Error("failed");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)]
|
||||||
|
#![allow(clippy::print_stderr)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
setup_panic_hook();
|
setup_panic_hook();
|
||||||
test_server::servers::run_all_servers();
|
test_server::servers::run_all_servers();
|
||||||
|
|
|
@ -162,6 +162,12 @@ async function clippy() {
|
||||||
"warnings",
|
"warnings",
|
||||||
"--deny",
|
"--deny",
|
||||||
"clippy::unused_async",
|
"clippy::unused_async",
|
||||||
|
// generally prefer the `log` crate, but ignore
|
||||||
|
// these print_* rules if necessary
|
||||||
|
"--deny",
|
||||||
|
"clippy::print_stderr",
|
||||||
|
"--deny",
|
||||||
|
"clippy::print_stdout",
|
||||||
],
|
],
|
||||||
stdout: "inherit",
|
stdout: "inherit",
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
|
|
Loading…
Reference in a new issue