mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(task): Task description in the form of comments (#23101)
Closes #22786.
TLDR;
```jsonc
{
"tasks": {
// Some comment
//
// describing what the task does
"dev": "deno run -A --watch main.ts"
}
}
```
```bash
deno task
```

This commit is contained in:
parent
68fecc6de4
commit
2dc37f411e
14 changed files with 121 additions and 18 deletions
|
@ -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<IndexMap<String, String>, AnyError> {
|
||||
) -> Result<IndexMap<String, deno_config::Task>, 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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue