Skip to content

File / directory based executable conditions #244

@jahvon

Description

@jahvon

Extend the conditional execution system to support file and directory-based conditions. This would allow executables to run conditionally based on file existence, absence, or modification state, enabling more intelligent workflow automation.

File Existence Checks

executables:
  - name: setup-project
    serial:
      execs:
        - if: not fileExists("docker-compose.yml")
          cmd: docker-compose up -d postgres
        - if: fileExists("package.json") and not fileExists("node_modules")
          cmd: npm install

Directory Conditions

executables:
  - name: init-project
    serial:
      execs:
        - if: not dirExists(".git")
          cmd: git init
        - if: fileExists("requirements.txt") and not dirExists("venv")
          cmd: python -m venv venv

File Modification Tracking

executables:
  - name: build-pipeline
    serial:
      execs:
        - if: fileNewer("src/", "dist/") or not dirExists("dist")
          cmd: npm run build
        - if: fileChanged("**/*.go") or env["FORCE_TEST"] == "true"
          cmd: go test ./...

Content-Based Conditions

executables:
  - name: deployment-check
    parallel:
      execs:
        - if: fileChanged("Dockerfile") or fileChanged("go.mod")
          cmd: docker build -t myapp .
        - if: fileNewer("migrations/", ".last-migration")
          cmd: migrate up

Condition Functions

Basic File Operations

  • fileExists(path) - Check if file exists
  • dirExists(path) - Check if directory exists
  • fileEmpty(path) - Check if file is empty
  • dirEmpty(path) - Check if directory is empty

Modification Tracking

  • fileNewer(source, target) - Check if source is newer than target
  • fileChanged(pattern) - Check if files matching pattern changed since last run
  • fileModified(path, duration) - Check if file modified within duration
  • dirModified(path, duration) - Check if any file in directory modified

Advanced Patterns

  • fileMatches(path, pattern) - Check if file content matches regex
  • fileSize(path, operator, size) - Check file size conditions
  • glob(pattern) - Return files matching glob pattern for further checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions