Documentation
¶
Index ¶
- Variables
- func DiscoverModules(ctx context.Context, moduleDirs []string) ([]moduleconfig.UnvalidatedModuleConfig, error)
- func WalkDir(dir string, skipGitIgnoredFiles bool, ...) error
- type FileChange
- type FileChangeType
- type FileHashes
- type ModifyFilesTransaction
- type WatchEvent
- type WatchEventModuleAdded
- type WatchEventModuleChanged
- type WatchEventModuleRemoved
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("skip directory")
ErrSkip can be returned by the WalkDir callback to skip a file or directory.
Functions ¶
func DiscoverModules ¶
func DiscoverModules(ctx context.Context, moduleDirs []string) ([]moduleconfig.UnvalidatedModuleConfig, error)
DiscoverModules recursively loads all modules under the given directories (or if none provided, the current working directory is used).
func WalkDir ¶
func WalkDir(dir string, skipGitIgnoredFiles bool, fn func(path string, d fs.DirEntry) error) error
WalkDir performs a depth-first walk of the file tree rooted at dir, calling fn for each file or directory in the tree, including dir.
It will adhere to .gitignore files. The callback "fn" can return ErrSkip to skip recursion.
Types ¶
type FileChange ¶
type FileChange struct {
Change FileChangeType
Path string
}
func CompareFileHashes ¶
func CompareFileHashes(oldFiles, newFiles FileHashes) []FileChange
CompareFileHashes compares the hashes of the files in the oldFiles and newFiles maps.
Returns all file changes
type FileChangeType ¶
type FileChangeType rune
const (
FileAdded FileChangeType = '+'
FileRemoved FileChangeType = '-'
FileChanged FileChangeType = '*'
)
type FileHashes ¶
type FileHashes map[string][]byte
func ComputeFileHashes ¶
func ComputeFileHashes(dir string, skipGitIgnoredFiles bool, patterns []string) (FileHashes, error)
ComputeFileHashes computes the SHA256 hash of all files in the given directory.
If skipGitIgnoredFiles is true, files that are ignored by git will be skipped.
type ModifyFilesTransaction ¶
type ModifyFilesTransaction interface {
Begin() error
ModifiedFiles(paths ...string) error
End() error
}
ModifyFilesTransaction allows builds to modify files in a module without triggering a watch event. This helps us avoid infinite loops with builds changing files, and those changes triggering new builds.as a no-op
type WatchEvent ¶
type WatchEvent interface {
// contains filtered or unexported methods
}
A WatchEvent is an event that occurs when a module is added, removed, or changed.
type WatchEventModuleAdded ¶
type WatchEventModuleAdded struct {
Config moduleconfig.UnvalidatedModuleConfig
}
type WatchEventModuleChanged ¶
type WatchEventModuleChanged struct {
Config moduleconfig.UnvalidatedModuleConfig
Changes []FileChange
Time time.Time
}
type WatchEventModuleRemoved ¶
type WatchEventModuleRemoved struct {
Config moduleconfig.UnvalidatedModuleConfig
}
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
func NewWatcher(lockPath optional.Option[string], patterns ...string) *Watcher
func (*Watcher) GetTransaction ¶
func (w *Watcher) GetTransaction(moduleDir string) ModifyFilesTransaction