Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: running same task twice #29

Closed
metaist opened this issue Jul 24, 2024 · 4 comments
Closed

fix: running same task twice #29

metaist opened this issue Jul 24, 2024 · 4 comments

Comments

@metaist
Copy link
Owner

metaist commented Jul 24, 2024

While I was figuring out #21, I ended up adding in logic to prevent circularity. However, this also prevents the same task from running twice. But, ironically, having #21 done meant that it is easy to define a task with an argument and then have other tasks call it with different arguments.

[scripts]
build = "touch build/$1"
clean = "rm -rf build"
all = ["clean", "-mkdir build", "build foo", "build bar", "echo 'Done'"]
  • Currently: runs clean, mkdir build, build foo, echo 'Done' (skips build bar)
  • Expected: all of the steps run
@metaist
Copy link
Owner Author

metaist commented Jul 24, 2024

Here's my analysis:

build => |touch
clean => |rm
all => clean => |mkdir => build => build => |echo

So is the problem when a composite task is called multiple times?

@metaist
Copy link
Owner Author

metaist commented Jul 24, 2024

Only composite tasks can call other tasks. So the concern is that in the call chain you somehow end up calling yourself again.

Here's the simplest loop:

[scripts]
loop = ["loop"]
# loop => loop ...

If a composite task cannot be called twice, we prevent this loop.

@metaist
Copy link
Owner Author

metaist commented Jul 24, 2024

Here's a more complicated loop:

[scripts]
a = ["b"]
b = ["a"]
# a=> b => a => b...

Ok, so far so good.

@metaist
Copy link
Owner Author

metaist commented Jul 24, 2024

What about a more real-world use case:

[scripts]
clean = ["rm -rf build", "rm build-artifacts"]
build = "touch build/$1"
run = ["clean", "build foo", "mv foo new-location", "clean"]

In this case, clean is a composite task, but we're calling it twice at the same level-- it's not cycling back to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant