guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
138 stars 7 forks source link

Task interpolation results in truncated paths #129

Closed Hypercubed closed 2 years ago

Hypercubed commented 2 years ago

Please see the following gist. I created a task (two actually with the same result). When running a "wildcard" task as expected the task runs for each dep. However, the $DEP and $TARGET values contain truncated paths.

https://gist.github.com/Hypercubed/c5c11a4ba3bc164ac1165e08ea603740

guybedford commented 2 years ago

This is because we don't currently fully support a ./ at the start of a path. We always assume paths start without ../ or ./ or / and are not absolute paths and are relative to the chompfile. We should definitely improve this support though as it's a clear pitfall.

Hypercubed commented 2 years ago

Yep... I see that removing the path from run1 works:

[[task]]
name = 'run1:#'
dep = '#.txt'
target = '#.out'
validation = 'ok-only'
run = 'echo $DEP $TARGET'

However, run2 requires a path:

[[task]]
name = 'run2:##'
dep = '##.txt'
target = '##.out'
validation = 'ok-only'
run = 'echo $DEP $TARGET'
Error: Unable to apply deep globbing to interpolate ##.txt. Deep globbing interpolates are only supported for full paths with '##' immediately following a separator position.
guybedford commented 2 years ago

Interesting, that's two separate bugs then. Lucky there's a workaround for both!

Added a fix for the second case in https://github.com/guybedford/chomp/commit/255af4ae5edcfc94733a8640e0a6cac01091be7b.

Hypercubed commented 2 years ago

Is there a reason why paths can't start with ../? I am doing that.. I have a monorepo where test fixtures are located outside of each project file.

Example: https://github.com/Hypercubed/f-flat-minor/blob/3eb28867d11c3ccb8e4dd0780fc4dec93c87689a/deno/chompfile.toml#L72

guybedford commented 2 years ago

No reason, I just haven't handled path normalization that way so it would be a large change, happy to create a tracking issue for it though.

Hypercubed commented 2 years ago

Wish I had the rust skills to contribute. I think this change will kill my usage. You mentioned a work around? Only thing I can think of is using absolute paths... not very portable.

guybedford commented 2 years ago

I will see if I can do the refactoring, it's simply a case of updating the pathing structure throughout the codebase to be resolved paths and not relative paths. Posted https://github.com/guybedford/chomp/issues/131.