chomp icon indicating copy to clipboard operation
chomp copied to clipboard

Depending on files that are targets of other tasks

Open jollytoad opened this issue 9 months ago • 2 comments

So I'm trying to create a build where I have multiple packages, that will build into separate output dirs.

For example src/one will end up in dst/one.

I was trying to create tasks to process files from src to dst:

[[task]]
target = 'dst/#/manifest.yml'
dep = 'src/#/manifest.yml'
run = 'cp $DEP $TARGET'

(cp is just for example, in reality i may have some transformation process)

This does exactly what I expect:

chomp dst/one/manifest.yml

There will be many more tasks that process stuff from src to dst, so I'd like a build:<name> task to handle that, but for this example I'll stick to the one file:

[[task]]
name = 'build:#'
dep = 'dst/#/manifest.yml'

after deleting dst, I run:

chomp build:one

but get:

Error: File /..../dst/one/manifest.yml not found

TBH, I expected that to trigger the first task and cp the file into dst.

Am I miss understanding how chomp works, should I be doing this differently, or is this an actual bug?

jollytoad avatar May 08 '25 10:05 jollytoad

Yes this is supposed to work but it's a bug in the implementation we don't support this properly. Unfortunately it needs workarounds for now unless someone is interested in working on this problem.

guybedford avatar May 08 '25 23:05 guybedford

Thanks @guybedford.

I tried adding a couple of test cases for this, with fixtures:

test/many/
  one/config.yml
  two/config.yml

First to verify that a task without wildcard and a lone dep will invoke the wildcard target task, and that works ok:

# -- Test --
[[task]]
name = 'test8'
dep = './output/dist/one/config.yml'

[[task]]
target = './output/dist/#/config.yml'
dep = './fixtures/many/#/config.yml'
run = 'cp $DEP $TARGET'

Next, i added a task for my issue above, ie. a wildcard name to a dep containing the wildcard, this should invoke the task above. And I added a test9 that depends upon this so that it gets invoked within the whole run of the test suite:

# -- Test --
[[task]]
name = 'test9'
dep = 'test9:build:two'

[[task]]
name = 'test9:build:#'
dep = './output/dist/#/config.yml'

This gives me the error and fails to run any other test tasks:

Error: File /Users/mgibson/github/chomp/test/output/dist/two/config.yml not found

But I also noticed that the dep = 'test9:build:two' doesn't seem to work either, if I remove the wildcard dep:

# -- Test --
[[task]]
name = 'test9'
dep = 'test9:build:two'

[[task]]
name = 'test9:build:#'
run = 'echo BUILD TEST9`

I get:

Error: File test9:build:two not found

Which I didn't expect either!

jollytoad avatar May 09 '25 09:05 jollytoad