diff --git a/lib/private/write_source_file.bzl b/lib/private/write_source_file.bzl index d5ff41e..f5e85d2 100644 --- a/lib/private/write_source_file.bzl +++ b/lib/private/write_source_file.bzl @@ -201,7 +201,7 @@ fi"""] if ctx.attr.executable: executable_file = "chmod +x \"$out\"" - executable_dir = "chmod -R +x \"$out\"/*" + executable_dir = "chmod -R +x \"$out\"" else: executable_file = "chmod -x \"$out\"" if is_macos: @@ -209,7 +209,7 @@ fi"""] executable_dir = "find \"$out\" -type f | xargs chmod -x" else: # Remove execute/search bit recursively from files bit not directories: https://superuser.com/a/434418 - executable_dir = "chmod -R -x+X \"$out\"/*" + executable_dir = "chmod -R -x+X \"$out\"" for in_path, out_path in paths: contents.append(""" @@ -231,10 +231,10 @@ else echo "Copying directory $in to $out in $PWD" # in case `cp` from previous command was terminated midway which can result in read-only files/dirs chmod -R ug+w "$out" > /dev/null 2>&1 || true - rm -Rf "$out"/* + rm -Rf "$out"/{{*,.[!.]*}} mkdir -p "$out" - cp -fRL "$in"/* "$out" - chmod -R ug+w "$out"/* + cp -fRL "$in"/. "$out" + chmod -R ug+w "$out" {executable_dir} fi """.format( diff --git a/lib/tests/write_source_files/BUILD.bazel b/lib/tests/write_source_files/BUILD.bazel index fca6e1f..56a5486 100644 --- a/lib/tests/write_source_files/BUILD.bazel +++ b/lib/tests/write_source_files/BUILD.bazel @@ -101,6 +101,19 @@ output_files( target = ":g_h-desired", ) +genrule( + name = "hidden-contained", + outs = [".hidden"], + cmd = "echo 'hidden file test' > $@", +) + +copy_to_directory( + name = "hidden_dir-desired", + srcs = [ + ":hidden-contained", + ], +) + write_source_file_test( name = "a_test", in_file = ":a-desired", @@ -137,6 +150,12 @@ write_source_file_test( out_file = "g.js", ) +write_source_file( + name = "hidden_dir_test", + in_file = ":hidden_dir-desired", + out_file = "hidden_dir", +) + write_source_files( name = "macro_smoke_test", additional_update_targets = [ diff --git a/lib/tests/write_source_files/hidden_dir/.hidden b/lib/tests/write_source_files/hidden_dir/.hidden new file mode 100644 index 0000000..cc889dc --- /dev/null +++ b/lib/tests/write_source_files/hidden_dir/.hidden @@ -0,0 +1 @@ +hidden file test