mod/modzip: check for cue.mod existence, not just directories
The codebase is inconsistent about whether cue.mod must be a directory:
- isModRoot() in cue/load/config.go checks existence only, with a comment
noting "cue.mod used to be a file. We still allow both to match."
- Module loading rejects file-based cue.mod with an error message.
- cmd/cue/cmd/modinit.go checks IsDir() and rejects files.
For submodule detection during directory walks, we should be consistent
with isModRoot() and accept either a file or directory. This handles
the case where someone has a legacy cue.mod file marking a submodule.
Simplify the check to just verify cue.mod exists, without requiring
it to be a directory.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I4d089ac6f439057306c0bf2c2992ce5391a59046
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229772
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>