Skip to content

Commit

Permalink
Log number of projects in workspace.list
Browse files Browse the repository at this point in the history
  • Loading branch information
pnezis committed Jul 5, 2024
1 parent c50e3c9 commit ce17937
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions workspace/lib/mix/tasks/workspace.list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ defmodule Mix.Tasks.Workspace.List do

defp list_workspace_projects(workspace, show_status) do
projects = Workspace.projects(workspace)

case Enum.count(projects, &(not &1.skip)) do
0 ->
Cli.log([:bright, :yellow, "No matching projects for the given options", :reset])

valid ->
Cli.log([
"Found ",
:bright,
:blue,
"#{valid} workspace projects",
:reset,
" matching the given options."
])
end

max_project_length = max_project_length(projects)

projects
Expand Down
13 changes: 13 additions & 0 deletions workspace/test/mix/tasks/workspace.list_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Mix.Tasks.Workspace.ListTest do

test "prints the tree of the workspace" do
expected = """
Found 11 workspace projects matching the given options.
* :package_default_a package_default_a/mix.exs :shared, area:core
* :package_default_b package_default_b/mix.exs - a dummy project
* :package_default_c package_default_c/mix.exs
Expand All @@ -38,6 +39,7 @@ defmodule Mix.Tasks.Workspace.ListTest do

test "with --show-status flag" do
expected = """
Found 11 workspace projects matching the given options.
* :package_changed_a ● package_changed_a/mix.exs :shared, area:core
* :package_changed_b ✔ package_changed_b/mix.exs - a dummy project
* :package_changed_c ● package_changed_c/mix.exs
Expand All @@ -58,6 +60,7 @@ defmodule Mix.Tasks.Workspace.ListTest do

test "with --project option set" do
expected = """
Found 2 workspace projects matching the given options.
* :package_default_a package_default_a/mix.exs :shared, area:core
* :package_default_b package_default_b/mix.exs - a dummy project
"""
Expand All @@ -72,10 +75,20 @@ defmodule Mix.Tasks.Workspace.ListTest do
"package_default_b"
])
end) == expected

assert capture_io(fn ->
ListTask.run([
"--workspace-path",
@sample_workspace_default_path,
"-p",
"invalid"
])
end) =~ "No matching projects for the given options"
end

test "with --exclude option set" do
expected = """
Found 1 workspace projects matching the given options.
* :package_default_b package_default_b/mix.exs - a dummy project
"""

Expand Down

0 comments on commit ce17937

Please sign in to comment.