lang: Pass through the Fs and the FsURI
This should give us options as to how a function should interact with an FS. I feel like it's cleaner to go through the World API, and passing in the FsURI lets us do that, but I passed in the Fs at the same time in case it's useful for some reason. I think using it is a boundary violation, but it's just a hunch. Does anything break when we move from one deploy to the next?
This commit is contained in:
@@ -142,6 +142,10 @@ type Data struct {
|
||||
// system to manage file resources or other aspects.
|
||||
Fs engine.Fs
|
||||
|
||||
// FsURI is the fs URI of the active filesystem. This is useful to pass
|
||||
// to the engine.World API for further consumption.
|
||||
FsURI string
|
||||
|
||||
// Base directory (absolute path) that the running code is in. If an
|
||||
// import is found, that's a recursive addition, and naturally for that
|
||||
// run, this value would be different in the recursion.
|
||||
|
||||
@@ -115,6 +115,16 @@ type NamedArgsFunc interface {
|
||||
// TODO: Consider combining this with the existing Data struct or more of it...
|
||||
// TODO: Do we want to add line/col/file values here, and generalize this?
|
||||
type FuncData struct {
|
||||
// Fs represents a handle to the filesystem that we're running on. This
|
||||
// is necessary for opening files if needed by import statements. The
|
||||
// file() paths used to get templates or other files from our deploys
|
||||
// come from here, this is *not* used to interact with the host file
|
||||
// system to manage file resources or other aspects.
|
||||
Fs engine.Fs
|
||||
|
||||
// FsURI is the fs URI of the active filesystem. This is useful to pass
|
||||
// to the engine.World API for further consumption.
|
||||
FsURI string
|
||||
|
||||
// Base directory (absolute path) that the running code is in. This is a
|
||||
// copy of the value from the Expr and Stmt Data struct for Init.
|
||||
|
||||
Reference in New Issue
Block a user