Przeglądaj źródła

Merge pull request #418 from exercism/prune-extra-keep-files

Add script to prune extraneous .keep files
John Ryan 9 lat temu
rodzic
commit
7c4dea9dc3
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12
    0
      scripts/prune-extra-keep-files.sh

+ 12
- 0
scripts/prune-extra-keep-files.sh Wyświetl plik

@@ -0,0 +1,12 @@
1
+#!/usr/bin/env bash
2
+
3
+for EXERCISE_DIRECTORY in $(find exercises -mindepth 2 -maxdepth 2 -type d -name "src"); do
4
+  STARTER_DIRECTORY="${EXERCISE_DIRECTORY}/main/java"
5
+  STARTER_FILE_COUNT=$(find "${STARTER_DIRECTORY}" -mindepth 1 -maxdepth 1 -type f -name "*.java" | wc -l)
6
+  KEEP_FILE_LOCATION="${STARTER_DIRECTORY}/.keep"
7
+
8
+  if (( ${STARTER_FILE_COUNT} > 0 )) && [[ -f "${KEEP_FILE_LOCATION}" ]]; then
9
+    echo "Removing unnecessary keep file ${KEEP_FILE_LOCATION}..."
10
+    rm "${KEEP_FILE_LOCATION}"
11
+  fi
12
+done