I need to read the contents of a `.env` file into ...
# plugins
a
I need to read the contents of a
.env
file into a
FrozenDict
- since the
.env
will not be version-controlled it can't have a target - does it make sense to write a rule that is not cacheable to read the contents or is there a better built-in way for this sort of thing?
f
Use the digest API to capture the file contents to a
Digest
digest = await Get(Digest, PathGlobs(…))
That will be cached. File changes will invalidate the cache as expected.
Rule code should generally not read directly from the filesystem with other APIs.
If you need the actual content, convert the digest to a
DigestContents
r
Ah I didn’t realize file changes would invalidate the cache for files that were not associated with targets.
f
Targets are a higher level API. Sources for targets are themselves captured via the digest API.
🙏 1