T
Task•4w ago
noel

Rerun task on dep build.

Is there a way to make a task run when one of it's deps was rebuilt in the current run
2 Replies
andreynering
andreynering•4w ago
Hi @noel, Perhaps you could paste a small example Taskfile on what exactly you're trying to do? What is preventing that task to run? Is it fingerprinting (via sources:) or are you using run: :once?
noel
noelOP•4w ago
It is fingerprinting via sources. And im using run:once. Btw how can i use variables inside generates or sources.
generates: [ "{{.MY_VAR}}" ]
generates: [ "{{.MY_VAR}}" ]
Does this look right ? Is there a way to debug why a task did or didnt run ? Here is a sample taskfile.
version: '3'

silent: true
run: once
method: timestamp

vars:
CLIENT_TARGET: /Users/foo/client/dist/api.js


tasks:
my-client:
desc: "Building client"
dir: /Users/foo/client
sources: ["**/*.ts"]
generates: [ {{.CLIENT_TARGET}} ]
cmds:
- echo "🚀 Building client"
- chronic npm run build

build-worker:
desc: "Building worker"
deps: [my-client]
dir: /Users/foo/worker
sources: ["**/*.js", "{{.CLIENT_TARGET}}" ]
cmds:
- echo "🚀 Building worker"
- chronic pm2 restart worker


all:
desc: "Built all"
deps: [ build-worker, my-client]
version: '3'

silent: true
run: once
method: timestamp

vars:
CLIENT_TARGET: /Users/foo/client/dist/api.js


tasks:
my-client:
desc: "Building client"
dir: /Users/foo/client
sources: ["**/*.ts"]
generates: [ {{.CLIENT_TARGET}} ]
cmds:
- echo "🚀 Building client"
- chronic npm run build

build-worker:
desc: "Building worker"
deps: [my-client]
dir: /Users/foo/worker
sources: ["**/*.js", "{{.CLIENT_TARGET}}" ]
cmds:
- echo "🚀 Building worker"
- chronic pm2 restart worker


all:
desc: "Built all"
deps: [ build-worker, my-client]
What i wanted: to run task all and it to only run cmds for worker if either its sources change or if deps were rebuilt. But now after i added var. If i run task my-client it reruns everytime, even if generates file has newer timestamp. It works as intended if i hardcode the values instead of using variables. update: when i got rid of method: timestamp, task my-client seems to skip when there are no changes in the src as expected. But build-worker doesn't seem to rebuild even when my-client builds update: i realize that i since im now using hash instead of timestamp and I my test changes didnt changes the content of this specific output file. So i updated the CLIENT_TARGET to /Users/foo/client/dist/**/*.js . But still doesnt seem to work as expected. Do you reckon it would be nice to have something like make --debug which tell you exactly why a target had to be rebuilt. btw. fyi. I was only testing out Taskfile because it seemed so much cleaner than make. I love the docs, and api. and how much cleaner it is. Would really love a --debug option though.
Want results from more Discord servers?
Add your server