Ability to dynamically define sources using `sh`
I have a task that needs to re-run whenever any tracked file in the entire folder changes (I use git to track what is a "tracked file"). I wanted to use **/* as the pattern, but obviously this doesn't work without tweaking, because the task will pick up changes in the build artifacts that the task itself produces.
The simplest approach would just be to allow for:
sources:
sh: <given filenames on stdin, exit or stdout line determines whether it is an input>
I could also make do with something like sources: { include: [...], exclude: [...] }.
PS: Just wanted to thank you for this amazing tool. I really like that you have sparse, minimal feature set that composes in powerful ways (e.g. recursive invocation).
In case you're curious why I need such a thing, here's my Taskfile.yml:
## Tasks
build_server:
desc: Build the server code
dir: server
cmds:
- dotnet build
build_client:
desc: Build the client code
dir: client
cmds:
- yarn && yarn build
build:
desc: Build everything
cmds:
- task: run_in_docker
vars: { TASK: build_server, IMAGE: microsoft/dotnet }
- task: run_in_docker
vars: { TASK: build_client, IMAGE: node }
## Utilities
run_in_docker:
deps:
- build_gotask
- task: upload_volume
vars: { VOL: app, DIR: . }
cmds:
- docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v app:/code -w /code {{.IMAGE}} ./bin/task -ws {{.TASK}}
# Hackery to work around lack of volume support for remote Docker instances
upload_volume:
sources: [./client/**/*.js, ./server/**/*.cs, ./Taskfile.yml]
generates: []
method: checksum
cmds:
- test -e ./lock && exit 0 || echo "building"
- echo "" > ./lock
- docker create --name helper -v {{.VOL}}:/x busybox > /dev/null
- docker cp {{.DIR}}/. helper:/x > /dev/null
- docker rm helper > /dev/null
- rm ./lock
# Build gotask binary
build_gotask:
cmds:
- docker run --rm golang bash -c "go get -u -v -ldflags '-linkmode external -extldflags -static' -a github.com/go-task/task/cmd/task && cat /go/bin/task" > ./bin/task
status:
- test -e ./bin/task
Just wanted to thank you for this amazing tool. I really like that you have sparse, minimal feature set that composes in powerful ways (e.g. recursive invocation).
Thanks! I'm glad that you found it helpful. 😉
I think your proposal makes sense. I'll keep this issue open until someone has time to work on it.
Just an thought on the syntax, if someone want to implement it.
I think along with sh:, we should allow not: (or maybe !?):
sources:
- **/*
- not: *.exe
Or alternatively (?):
sources:
- **/*
- !*.exe
Sorry, was just cleaning out some old issues. Just noticed you're still tracking this for the next release.
As negating sources is now possible, I'm going to retitle this issue so that it is more specially about dynamic sources