Documentation
¶
Index ¶
Constants ¶
View Source
const ModuleName = "fs"
ModuleName of the "fs" package
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FS ¶
type FS struct {
// CurrentWorkingDirectory set in the process module. Not that this must NOT be used to prepend paths
// but is rather to resolve files relative to CurrentWorkingDirectory when also a FileSystem is provided.
// This achieves the effect that when FileSystem is used, the 'proper' structure of that fileystem is preserved.
//
// An example of this would be having an embed.FS which is a directory containing the ruleset:
// go-embed testdata
// var fs embed.FS
//
// On the process module, the CurrentWorkingDirectory is set and provides the Cwd method. The JavaScript code
// already uses this on paths that are then provided to fs so the CurrentWorkingDirectory is already part of that
// This directory however most likely doesn't exist in embedded so that prefix is then stripped of such that
// the ruleset can still be referenced now using testdata/ruleset.yaml
CurrentWorkingDirectory string
// FileSystem if not nil is used to resolve e.g. embedded filesystems (embed.FS). These can contain bundled
// OpenAPI specs and/or rulesets. The files are resolved by trimming the CurrentWorkingDirectory prefix
// from paths and if there is a match that file is used. In case of no match, the search continues on the
// system file system using os.ReadFile.
FileSystem fs.FS
// contains filtered or unexported fields
}
FS struct initialization
func (*FS) LStat ¶
func (f *FS) LStat(call goja.FunctionCall) goja.Value
LStat translated to os.Lstat but returning false for isDirectory isSymbolicLink isBlockDevice isCharacterDevice isFIFO isSocket and always true for isFile. Note that this most likely breaks glob patterns with directories and this method should be properly implemented TODO fix LStat such that the returned values are correct for also directories / symlinks
func (*FS) Native ¶
func (f *FS) Native(_ goja.FunctionCall) goja.Value
Native asynchronous realpath. Not implemented
func (*FS) PromiseReadFile ¶
func (f *FS) PromiseReadFile(call goja.FunctionCall) goja.Value
PromiseReadFile using os.ReadFile
Click to show internal directories.
Click to hide internal directories.