feat: commit code
This commit is contained in:
1 parent
78c78548e8
commit
8613518c40
1 file changed
+54
-4
+54
-4
@@ -495,7 +495,7 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
|||||||
log::info!("{}\n", "A perfect compilation!".green().bold());
|
log::info!("{}\n", "A perfect compilation!".green().bold());
|
||||||
} else {
|
} else {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"{}\n",
|
"{}",
|
||||||
format!(
|
format!(
|
||||||
"There were {} warning messages during the build: ",
|
"There were {} warning messages during the build: ",
|
||||||
options.warnings.len() - 1
|
options.warnings.len() - 1
|
||||||
@@ -504,13 +504,63 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
|||||||
.bold()
|
.bold()
|
||||||
);
|
);
|
||||||
for info in &options.warnings {
|
for info in &options.warnings {
|
||||||
if info.message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
let message = info.message.clone();
|
||||||
|
if message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(val) = info.rendered.clone() {
|
let mut console = String::new();
|
||||||
log::warn!("{}", val);
|
for span in &info.spans {
|
||||||
|
let file = &span.file_name;
|
||||||
|
let line = (span.line_start, span.line_end);
|
||||||
|
let line_str = if line.0 == line.1 {
|
||||||
|
line.0.to_string()
|
||||||
|
} else {
|
||||||
|
format!("{}~{}", line.0, line.1)
|
||||||
|
};
|
||||||
|
let code = span.text.clone();
|
||||||
|
// let span_info = format!(
|
||||||
|
// "[{}: {}]: {} --> {}",
|
||||||
|
// file,
|
||||||
|
// if line.0 == line.1 {
|
||||||
|
// line.0.to_string()
|
||||||
|
// } else {
|
||||||
|
// format!("{}~{}", line.0, line.1)
|
||||||
|
// },
|
||||||
|
// if code.len() == 1 {
|
||||||
|
// code.get(0).unwrap().text.trim().blue().bold().to_string()
|
||||||
|
// } else {
|
||||||
|
// format!("\n{}",code.iter()
|
||||||
|
// .enumerate()
|
||||||
|
// .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
||||||
|
// .collect::<String>())
|
||||||
|
// },
|
||||||
|
// message.yellow().bold()
|
||||||
|
// );
|
||||||
|
let span_info = if code.len() == 1 {
|
||||||
|
let code = code.get(0).unwrap().text.trim().blue().bold().to_string();
|
||||||
|
format!(
|
||||||
|
"[{}: {}]: '{}' --> {}",
|
||||||
|
file,
|
||||||
|
line_str,
|
||||||
|
code,
|
||||||
|
message.yellow().bold()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
let code = code
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
||||||
|
.collect::<String>();
|
||||||
|
format!("[{}: {}]:\n{}", file, line_str, code)
|
||||||
|
};
|
||||||
|
console = format!("{console}\n\t{span_info}");
|
||||||
}
|
}
|
||||||
|
println!("{console}");
|
||||||
}
|
}
|
||||||
|
println!(
|
||||||
|
"\n{}\n",
|
||||||
|
"Resolving all warnings will help your code run better!".yellow()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user