From 896e887bd1bb28f7cafe5b9ce482ee9fa4e9ec62 Mon Sep 17 00:00:00 2001 From: gemmaro Date: Wed, 20 Dec 2023 19:47:46 +0900 Subject: [PATCH] Accept FileList object as directory task's target --- lib/rake/dsl_definition.rb | 1 + test/test_rake_directory_task.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index a9dd9f820..6bd660cb6 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -90,6 +90,7 @@ def file_create(*args, &block) # directory "testdata/doc" # def directory(*args, &block) # :doc: + args = args.flat_map { |arg| arg.is_a?(FileList) ? arg.to_a.flatten : arg } result = file_create(*args, &block) dir, _ = *Rake.application.resolve_args(args) dir = Rake.from_pathname(dir) diff --git a/test/test_rake_directory_task.rb b/test/test_rake_directory_task.rb index 5635afd13..628344a1b 100644 --- a/test/test_rake_directory_task.rb +++ b/test/test_rake_directory_task.rb @@ -74,4 +74,16 @@ def test_can_use_pathname assert File.directory?("a/b/c") end + + def test_can_use_filelist + directory FileList["a", "b", "c"] + + assert_equal FileCreationTask, Task["a"].class + + verbose(false) { + Task["a"].invoke + } + + assert File.directory?("a") + end end