-
-
Notifications
You must be signed in to change notification settings - Fork 334
ExecForEach().Error() doesn't execute #123
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
Comments
Hey @philippgille, thanks for the report! Don't forget that all filters run concurrently. So calling If you immediately call You could write instead something like this: p := script.FindFiles(".").Match("coverage.txt").ExecForEach("rm ./{{.}}")
p.Wait()
return p.Error() |
Thanks for the super quick reply! Ah I see, I'd like to propose two things:
The great thing about If you agree, I could work on a PR. |
Yep, it would be great to have a Wait method with returning error. This can allow us to write in one line: if err := script.Exec("sleep 10").WaitError(); err != nil {
return err
} |
I like this idea 😁 |
@bitfield do you need someone to work on this? I would be happy to contribute |
Sure, go right ahead! |
@mahadzaryab1 the PR is great, but I wonder if we can really justify having two more or less identical methods, one that returns the error and one that doesn't. To play devil's advocate for a moment, if we already had After all, if |
@bitfield Sounds good to me! I'll make the change. |
@philippgille and @bcho, will this solution work for you? |
That's great, thank you! 👍 |
Hello, I'm currently trying to migrate from some
build.sh
andbuild.ps1
files to a magefile usingscript
.Maybe I misunderstood the purpose of
Error()
, but when I don't need the output of a command (asString()
would return), I thoughtError()
would basically ignore the output, but still return the error. But it seems that when chained after anExecForEach
, the commands in that are not executed.For example, let's say we have files
coverage.txt
andfoo/coverage.txt
and I want to remove them.Then the following works:
But the following doesn't:
Is that expected?
The text was updated successfully, but these errors were encountered: