From 4700f12ddc5427797333278d2a1d3a8e1195ebfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 27 Nov 2024 01:12:47 +0000 Subject: [PATCH] fix(task): handle carriage return in task description (#27099) Ref https://github.com/denoland/deno/pull/27069#discussion_r1857702814 --- cli/tools/task.rs | 2 +- tests/specs/task/description/deno.json | 4 ++++ tests/specs/task/description/main.out | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/tools/task.rs b/cli/tools/task.rs index 65b78f9c9b..1b83422ba9 100644 --- a/cli/tools/task.rs +++ b/cli/tools/task.rs @@ -721,7 +721,7 @@ fn print_available_tasks( )?; if let Some(description) = &desc.task.description { let slash_slash = colors::italic_gray("//"); - for line in description.split('\n') { + for line in description.lines() { writeln!(writer, " {slash_slash} {}", colors::italic_gray(line))?; } } diff --git a/tests/specs/task/description/deno.json b/tests/specs/task/description/deno.json index c8a79c00ee..028ae86210 100644 --- a/tests/specs/task/description/deno.json +++ b/tests/specs/task/description/deno.json @@ -7,6 +7,10 @@ "multiline_description": { "description": "This is a multiline\ndescription", "command": "echo 2" + }, + "multiline_description_carriage_return": { + "description": "This is a multiline\r\ndescription\r\n", + "command": "echo 3" } } } diff --git a/tests/specs/task/description/main.out b/tests/specs/task/description/main.out index 91cce4adf8..edc7535f2c 100644 --- a/tests/specs/task/description/main.out +++ b/tests/specs/task/description/main.out @@ -6,3 +6,7 @@ Available tasks: // This is a multiline // description echo 2 +- multiline_description_carriage_return + // This is a multiline + // description + echo 3