Skip to content

Conversation

lakshya1goel
Copy link

@lakshya1goel lakshya1goel commented Aug 28, 2025

Description

Adds support for colon-separated glob patterns in the sources field, allowing multiple patterns to be specified in a single line for more concise Taskfile syntax.

Fix : #1018

Problem

Currently, each glob pattern in sources must be specified as a separate array item:

tasks:
  build:
    sources:
      - "*.go"
      - "internal/**/*.go" 
      - "cmd/**/*.go"
    cmds:
      - go build

Solution

Enable colon-separated patterns within a single string:

tasks:
  build:
    sources:
      - "*.go:internal/**/*.go:cmd/**/*.go"
    cmds:
      - go build

Changes

  • Modified internal/templater/templater.go: Enhanced ReplaceGlobs function to split colon-separated patterns
  • Added integration test TestColonSeparatedSources
  • Updated documentation and JSON schema

Backwards Compatibility

Fully backwards compatible - existing Taskfiles work unchanged.

Example

vars:
  GO_FILES: "*.go:internal/**/*.go:cmd/**/*.go"

tasks:
  test:
    sources:
      - "{{.GO_FILES}}"
    cmds:
      - go test ./...

Testing

  • Integration test added and passing
  • All existing tests pass
  • Manual testing with various glob patterns

@lakshya1goel
Copy link
Author

Hi @andreynering, please review this PR, whenever you get some time.
Thank you!

@pd93
Copy link
Member

pd93 commented Aug 30, 2025

Tbh, I really don't like the foo:bar syntax for sources. Using a colon as a list separator feels like hidden behaviour and unintuitive when other sources are defined using YAML lists. I'm generally against having 2 ways of doing 1 thing.

IMO, now that we have proper variable types in Task, a better solution to #1018 would be to add support for the ref keyword to sources and pass a real YAML list into the tasks. For example:

before:

version: '3'

vars:
  PATHS:
    - 'path/1.js'
    - 'path/2.js'
    - 'path/**/*.js'

tasks:
  task-A:
    sources:
      - ref: .GLOB

  task-AB:
    sources:
      - ref: .GLOB
      - 'path/3.js'

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

Successfully merging this pull request may close these issues.

Allow : separator to define multiple paths on a single sources entry
2 participants