go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.37k stars 613 forks source link

Allow `:` separator to define multiple paths on a single `sources` entry #1018

Open eitsupi opened 1 year ago

eitsupi commented 1 year ago

I am using the following Taskfile, but there are several tasks that refer to partially overlapping sources, and I felt it would be useful to be able to specify multiple sources at once.

https://github.com/eitsupi/prqlr/blob/cade3aa1a8cd4c5b1a39b3ea38aea4d95d9e1fdc/Taskfile.yml#L42-L67

  test-source:
    sources:
      - tests/**/*
      - R/*
      - src/Makevars*
      - src/rust/Cargo.toml
      - src/rust/src/**/*.rs

  test-vignettes:
    sources:
      - vignettes/**/*.Rmd
      - R/*
      - src/Makevars*
      - src/rust/Cargo.toml
      - src/rust/src/**/*.rs

I would like to define R/*, src/Makevars*, src/rust/Cargo.toml, src/rust/src/**/*.rs somewhere and designate it collectively.

Originally posted by @eitsupi in https://github.com/go-task/task/discussions/1009

andreynering commented 1 year ago

Hi @eitsupi,

Note that you can use variables to share at least single source entries between tasks:

version: '3'

vars:
  GLOB: 'src/**/*.js'

tasks:
  task-A:
    sources:
      - '{{.GLOB}}'

  task-AB:
    sources:
      - '{{.GLOB}}'

Of course, that doesn't solve the whole problem given you need multiple entries. I'll keep this issue open so we can consider addressing this in the future.

I think a possible solution would be to allow a separator character (probably : to be consistent with PATH on Linux) so multiple paths could be set on a single source entry.

version: '3'

vars:
  GLOB: 'path/1.js:path/2.js:path/**/*.js'

tasks:
  task-A:
    sources:
      - '{{.GLOB}}'

  task-AB:
    sources:
      - '{{.GLOB}}'