From 2dc37f411e8947d3c20cd93d1fa1937edc239499 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:14:27 -0700 Subject: feat(task): Task description in the form of comments (#23101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #22786. TLDR; ```jsonc { "tasks": { // Some comment // // describing what the task does "dev": "deno run -A --watch main.ts" } } ``` ```bash deno task ``` ![Screenshot 2024-03-27 at 1 43 49 PM](https://github.com/denoland/deno/assets/17734409/7a14da8c-8e63-45ba-9bfb-590d250b56a9) --- cli/args/mod.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'cli/args/mod.rs') diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 330b10d0f..76de434fd 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -796,11 +796,18 @@ impl CliOptions { } else { None }; + let parse_options = deno_config::ParseOptions { + include_task_comments: matches!( + flags.subcommand, + DenoSubcommand::Task(..) + ), + }; let maybe_config_file = ConfigFile::discover( &flags.config_flag, flags.config_path_args(&initial_cwd), &initial_cwd, additional_config_file_names, + &parse_options, )?; let mut maybe_package_json = None; @@ -1183,7 +1190,7 @@ impl CliOptions { pub fn resolve_tasks_config( &self, - ) -> Result, AnyError> { + ) -> Result, AnyError> { if let Some(config_file) = &self.maybe_config_file { config_file.resolve_tasks_config() } else if self.maybe_package_json.is_some() { @@ -1850,7 +1857,12 @@ mod test { let cwd = &std::env::current_dir().unwrap(); let config_specifier = ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap(); - let config_file = ConfigFile::new(config_text, config_specifier).unwrap(); + let config_file = ConfigFile::new( + config_text, + config_specifier, + &deno_config::ParseOptions::default(), + ) + .unwrap(); let actual = resolve_import_map_specifier( Some("import-map.json"), Some(&config_file), @@ -1869,7 +1881,12 @@ mod test { let config_text = r#"{}"#; let config_specifier = ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap(); - let config_file = ConfigFile::new(config_text, config_specifier).unwrap(); + let config_file = ConfigFile::new( + config_text, + config_specifier, + &deno_config::ParseOptions::default(), + ) + .unwrap(); let actual = resolve_import_map_specifier( None, Some(&config_file), -- cgit v1.2.3