Browse Source

Move file-touching responsibility.

Herby Vojčík 4 years ago
parent
commit
6531cd8dd9
2 changed files with 15 additions and 6 deletions
  1. 10 5
      check-some-are-unignored.sh
  2. 5 1
      check-vcs-changes.sh

+ 10 - 5
check-some-are-unignored.sh

@@ -4,8 +4,13 @@ set -e -x
 PATHS="`IFS='
 ' paste -s -d:`"
 
-if [ -n "$PATHS" ] && node --eval "process.exit(require('ignore')().add(process.argv[1].split(',')).filter(process.argv[2].split(':')).length ? 0 : 1)" "$1" "$PATHS"; then
-  if [ -n "$2" ]; then touch "$2"; fi
-else
-  if [ -n "$3" ]; then touch "$3"; fi
-fi
+CODE="
+  process.exit(
+    require('ignore')()
+      .add(process.argv[1].split(','))
+      .filter(process.argv[2].split(':'))
+      .length
+    ? 0 : 1
+  )"
+
+[ -n "$PATHS" ] && node --eval "$CODE" "$1" "$PATHS"

+ 5 - 1
check-vcs-changes.sh

@@ -5,4 +5,8 @@ if [ -n "$PLUGIN_IGNORE" -a \( -n "$PLUGIN_POSITIVE" -o -n "$PLUGIN_NEGATIVE" \)
   set "$PLUGIN_IGNORE" "$PLUGIN_POSITIVE" "$PLUGIN_NEGATIVE"
 fi
 
-git diff --name-only "$DRONE_COMMIT_AFTER" "$DRONE_COMMIT_BEFORE" | ./check-some-are-unignored.sh "$1" "$2" "$3"
+if git diff --name-only "$DRONE_COMMIT_AFTER" "$DRONE_COMMIT_BEFORE" | ./check-some-are-unignored.sh "$1"; then
+  if [ -n "$2" ]; then touch "$2"; fi
+else
+  if [ -n "$3" ]; then touch "$3"; fi
+fi