Skip to content

Custom vendor dirs #95

@mikepqr

Description

@mikepqr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions