From 0e9da7e731cea3a073812c22da30d87209537a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 8 Jun 2020 14:06:20 +0200 Subject: feat: "deno lint" subcommand (#6125) --- cli/fmt_errors.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'cli/fmt_errors.rs') diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs index c8dfc625a..bfda1feb0 100644 --- a/cli/fmt_errors.rs +++ b/cli/fmt_errors.rs @@ -10,6 +10,15 @@ use std::ops::Deref; const SOURCE_ABBREV_THRESHOLD: usize = 150; +pub fn format_location(filename: String, line: i64, col: i64) -> String { + format!( + "{}:{}:{}", + colors::cyan(filename), + colors::yellow(line.to_string()), + colors::yellow(col.to_string()) + ) +} + pub fn format_stack( is_error: bool, message_line: String, @@ -137,11 +146,10 @@ impl fmt::Display for JSError { && self.0.line_number.is_some() && self.0.start_column.is_some() { - formatted_frames = vec![format!( - "{}:{}:{}", - colors::cyan(self.0.script_resource_name.clone().unwrap()), - colors::yellow(self.0.line_number.unwrap().to_string()), - colors::yellow((self.0.start_column.unwrap() + 1).to_string()) + formatted_frames = vec![format_location( + self.0.script_resource_name.clone().unwrap(), + self.0.line_number.unwrap(), + self.0.start_column.unwrap() + 1, )] }; -- cgit v1.2.3