hookscripts: glob hook directories

This commit is contained in:
Caleb Connolly
2023-04-07 01:13:15 +01:00
parent f0544999db
commit b54044a605
2 changed files with 8 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ func (f *FileList) Import(src *FileList) {
}
}
func (f *FileList) AddGlobbed(src string, dest string) (error) {
func (f *FileList) AddGlobbed(src string, dest string) error {
fFiles, err := misc.GetFiles([]string{src}, true)
if err != nil {
return fmt.Errorf("unable to add %q: %w", src, err)

View File

@@ -35,8 +35,13 @@ func (h *HookScripts) List() (*filelist.FileList, error) {
}
for _, file := range fileInfo {
path := filepath.Join(h.scriptsDir, file.Name())
log.Printf("-- Including script: %s\n", path)
files.Add(path, filepath.Join(h.destPath, file.Name()))
if file.IsDir() {
log.Printf("-- Including dir %s\n", path)
files.AddGlobbed(filepath.Join(path, "*"), filepath.Join(h.destPath, file.Name()))
} else {
log.Printf("-- Including script: %s\n", path)
files.Add(path, filepath.Join(h.destPath, file.Name()))
}
}
return files, nil
}