Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Nov 20, 2024
1 parent af5162c commit 14234f5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
20 changes: 10 additions & 10 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10315,7 +10315,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["hello", "world"],
Expand All @@ -10332,7 +10332,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
..Flags::default()
Expand Down Expand Up @@ -10443,7 +10443,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["--", "hello", "world"],
Expand All @@ -10463,7 +10463,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["--", "hello", "world"],
Expand All @@ -10484,7 +10484,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["--"],
Expand All @@ -10504,7 +10504,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["-1", "--test"],
Expand All @@ -10524,7 +10524,7 @@ mod tests {
task: Some("build".to_string()),
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
argv: svec!["--test"],
Expand Down Expand Up @@ -10565,7 +10565,7 @@ mod tests {
task: None,
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
..Flags::default()
Expand All @@ -10584,7 +10584,7 @@ mod tests {
task: None,
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
config_flag: ConfigFlag::Path("deno.jsonc".to_string()),
Expand All @@ -10604,7 +10604,7 @@ mod tests {
task: None,
is_run: false,
recursive: false,
filter: None
filter: None,
eval: false,
}),
config_flag: ConfigFlag::Path("deno.jsonc".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
task: Some(run_flags.script.clone()),
is_run: true,
recursive: false,
filter: None
filter: None,
eval: false,
};
new_flags.subcommand = DenoSubcommand::Task(task_flags.clone());
Expand Down
18 changes: 13 additions & 5 deletions cli/tools/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum TaskKind {
#[derive(Debug, Clone)]
struct TaskInfo {
kind: TaskKind,
folder_url: Url,
command: String,
description: Option<String>,
dependencies: Vec<String>,
Expand Down Expand Up @@ -262,7 +263,10 @@ pub async fn execute_script(
.run_deno_task(
&Url::from_directory_path(cli_options.initial_cwd()).unwrap(),
&"".to_string(),
&TaskDefinition {
&TaskInfo {
kind: TaskKind::Deno,
folder_url: Url::from_directory_path(cli_options.initial_cwd())
.unwrap(),
command: task_flags.task.as_ref().unwrap().to_string(),
dependencies: vec![],
description: None,
Expand Down Expand Up @@ -299,6 +303,7 @@ fn extract_tasks(
name.to_string(),
TaskInfo {
kind: TaskKind::Deno,
folder_url: deno_json.folder_url.clone(),
command: task.command.to_string(),
dependencies: task.dependencies.clone(),
description: task.description.clone(),
Expand All @@ -320,6 +325,7 @@ fn extract_tasks(
name.to_string(),
TaskInfo {
kind: TaskKind::Npm,
folder_url: pkg_json.folder_url.clone(),
command: task.to_string(),
dependencies: vec![],
description: None,
Expand Down Expand Up @@ -691,8 +697,8 @@ fn print_available_tasks(
tasks_config: &PackageTaskInfo,
) -> Result<(), std::io::Error> {
writeln!(writer, "{}", colors::green("Available tasks:"))?;
// let is_cwd_root_dir = tasks_config.root.is_none();
let is_cwd_root_dir = false;
let is_cwd_root_dir =
tasks_config.url.as_ref() == workspace_dir.workspace.root_dir().as_ref();

if tasks_config.tasks.is_empty() {
writeln!(
Expand All @@ -712,8 +718,8 @@ fn print_available_tasks(
let mut task_descriptions = Vec::with_capacity(tasks_config.tasks.len());

for (name, task) in &tasks_config.tasks {
let is_root = *tasks_config.url.as_ref()
== *workspace_dir.workspace.root_dir().as_ref();
let is_root = !is_cwd_root_dir
&& task.folder_url == *workspace_dir.workspace.root_dir().as_ref();

task_descriptions.push(AvailableTaskDescription {
is_root,
Expand All @@ -727,6 +733,8 @@ fn print_available_tasks(
});
}

task_descriptions.sort_by_cached_key(|d| d.name.to_string());

for desc in task_descriptions {
writeln!(
writer,
Expand Down

0 comments on commit 14234f5

Please sign in to comment.