Documentation ¶
Index ¶
- Variables
- func DiscoverModules(ctx context.Context, moduleDirs []string) ([]moduleconfig.UnvalidatedModuleConfig, error)
- func WalkDir(dir string, fn func(path string, d fs.DirEntry) error) error
- 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).
Types ¶
type FileChangeType ¶
type FileChangeType rune
const ( FileAdded FileChangeType = '+' FileRemoved FileChangeType = '-' FileChanged FileChangeType = '*' )
func CompareFileHashes ¶
func CompareFileHashes(oldFiles, newFiles FileHashes) (FileChangeType, string, bool)
CompareFileHashes compares the hashes of the files in the oldFiles and newFiles maps.
Returns true if the hashes are equal, false otherwise.
If false, the returned string will be a file that caused the difference and the returned FileChangeType will be the type of change that occurred.
func (FileChangeType) GoString ¶
func (f FileChangeType) GoString() string
func (FileChangeType) String ¶
func (f FileChangeType) String() string
type FileHashes ¶
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 Change FileChangeType Path string Time time.Time }
type WatchEventModuleRemoved ¶
type WatchEventModuleRemoved struct {
Config moduleconfig.UnvalidatedModuleConfig
}
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
func (*Watcher) GetTransaction ¶
func (w *Watcher) GetTransaction(moduleDir string) ModifyFilesTransaction