Преглед изворни кода

improve naming of directory-is-empty

Christian Winther пре 1 година
родитељ
комит
8189b01a26
2 измењених фајлова са 4 додато и 3 уклоњено
  1. 1 1
      docker/shared/root/docker/entrypoint.sh
  2. 3 2
      docker/shared/root/docker/helpers.sh

+ 1 - 1
docker/shared/root/docker/entrypoint.sh

@@ -31,7 +31,7 @@ IFS=' ' read -ar skip_scripts <<< "$ENTRYPOINT_SKIP_SCRIPTS"
 mkdir -p "${ENTRYPOINT_D_ROOT}"
 
 # If ENTRYPOINT_D_ROOT directory is empty, warn and run the regular command
-if is-directory-empty "${ENTRYPOINT_D_ROOT}"; then
+if directory-is-empty "${ENTRYPOINT_D_ROOT}"; then
     log-warning "No files found in ${ENTRYPOINT_D_ROOT}, skipping configuration"
 
     exec "$@"

+ 3 - 2
docker/shared/root/docker/helpers.sh

@@ -317,13 +317,14 @@ function file-exists()
 {
     [[ -f "$1" ]]
 }
+
 # @description Checks if $1 contains any files or not
 # @arg $1 string The path to check
 # @exitcode 0 If $1 contains files
 # @exitcode 1 If $1 does *NOT* contain files
-function is-directory-empty()
+function directory-is-empty()
 {
-    ! find "${1}" -mindepth 1 -maxdepth 1 -type f -print -quit 2> /dev/null | read -r
+    [ -z "$(ls -A "${1}")" ]
 }
 
 # @description Ensures a directory exists (via mkdir)