It is difficult to get make-like behaviour with target.Path
There are two cases in make where a rule is executed:
- the target does not exist.
- the target is older than one of the sources.
target.Path(dst, sources...) returns true, nil on (2), but returns false, err on (1). That leads me to think that maybe I could do something like this:
outOfDate, err := target.Path(dst, source1, source2)
if err != nil && !os.IsNotExist(err) {
return err
}
if outOfDate || os.IsNotExist(err) {
... action ...
}
Unfortunately, if any of the sources doesn't exist, I will also get an os.IsNotExist() also returning true so I can't distinguish between the target not existing and one of the sources existing.
Hm... so this sounds like a bug. The destination not existing should just return true, nil. not existing is definitely out of date. Only the source not existing should be an error. We should get that fixed.
Also, I see that the docs on these functions are not sufficient, since they don't explain what happens with not existing.
Thanks for the report. I'll try to get to this soon (or you're welcome to submit a PR).
Sure, I'll submit a PR later today
PR submitted
Thank you!
fixed by 131. If there's a different behavior you'd like, we can add it to another function, perhaps.