Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom vendor dirs #95

Open
mikepqr opened this issue Jun 5, 2024 · 0 comments
Open

Custom vendor dirs #95

mikepqr opened this issue Jun 5, 2024 · 0 comments

Comments

@mikepqr
Copy link

mikepqr commented Jun 5, 2024

I have several directory/sentinels I would like to exclude that are not generally applicable. This raises the possibility of a per-user configuration file whose contents get appended to ASIMOV_VENDOR_DIR_SENTINELS. Something like:

diff --git a/asimov b/asimov
index 81df4a7..e963344 100755
--- a/asimov
+++ b/asimov
@@ -19,6 +19,8 @@ set -Eeu -o pipefail

 readonly ASIMOV_ROOT=~

+readonly ASIMOV_CUSTOM_VENDOR_DIR_FILE="${HOME}/.config/asimov"
+
 # Paths to unconditionally skip over. This prevents Asimov from modifying the
 # Time Machine exclusions for these paths (and decendents). It has an important
 # side-effect of speeding up the search.
@@ -33,7 +35,7 @@ readonly ASIMOV_SKIP_PATHS=(
 #
 # For example, 'node_modules package.json' means "exclude node_modules/ from the
 # Time Machine backups if there is a package.json file next to it."
-readonly ASIMOV_VENDOR_DIR_SENTINELS=(
+readonly ASIMOV_DEFAULT_VENDOR_DIR_SENTINELS=(
     '.build Package.swift'             # Swift
     '.gradle build.gradle'             # Gradle
     '.gradle build.gradle.kts'         # Gradle Kotlin Script
@@ -72,6 +74,17 @@ readonly ASIMOV_VENDOR_DIR_SENTINELS=(
     'cdk.out cdk.json'                 # AWS CDK
 )

+if [ -f "$ASIMOV_CUSTOM_VENDOR_DIR_FILE" ]; then
+    mapfile -t ASIMOV_CUSTOM_VENDOR_DIR_SENTINELS <"$ASIMOV_CUSTOM_VENDOR_DIR_FILE"
+else
+    readonly ASIMOV_CUSTOM_VENDOR_DIR_SENTINELS=()
+fi
+
+readonly ASIMOV_VENDOR_DIR_SENTINELS=(
+    "${ASIMOV_DEFAULT_VENDOR_DIR_SENTINELS[@]}"
+    "${ASIMOV_CUSTOM_VENDOR_DIR_SENTINELS[@]}"
+)
+
 # Exclude the given paths from Time Machine backups.
 # Reads the newline-separated list of paths from stdin.
 exclude_file() {

This needs some work (e.g. validation of the contents of the configuration file), documentation, etc. but would you take a PR along these lines? Any comments on what I have so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant