Skip to content

Commit

Permalink
include paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmonsays committed Apr 1, 2024
1 parent cc558e9 commit 7b9e7e3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,19 @@ func (me *Link) RunFile(opts *LinkOptions, path string) error {
cfg.PrintConfig()
}

return me.RunConfig(opts, cfg)
// change directory to directory of configuration file
dir := filepath.Dir(path)
err = os.Chdir(dir)
if err != nil {
log.Errorf("Chdir %s: %s", dir, err)
return err
}
log.Tracef("RunFile %s (in %s)", path, dir)

return me.RunConfig(path, opts, cfg)
}

func (me *Link) RunConfig(opts *LinkOptions, cfg *AppConfig) error {
func (me *Link) RunConfig(path string, opts *LinkOptions, cfg *AppConfig) error {
run, err := CompileRun(cfg.Symlinks, cfg.Script)
if err != nil {
return err
Expand All @@ -109,20 +118,22 @@ func (me *Link) RunConfig(opts *LinkOptions, cfg *AppConfig) error {
return err
}

err = me.ProcessIncludes(opts, cfg.Include, run)
err = me.ProcessIncludes(path, opts, cfg.Include, run)
if err != nil {
return err
}

return nil
}

func (me *Link) ProcessIncludes(opts *LinkOptions, includes []string, run *Run) error {
func (me *Link) ProcessIncludes(path string, opts *LinkOptions, includes []string, run *Run) error {
if len(includes) == 0 {
log.Tracef("no includes to process")
log.Tracef("no includes to process in %s", path)
return nil
}

for _, include := range includes {
log.Tracef("Processing include %s", include)

matches, err := filepath.Glob(include)
if err != nil {
Expand Down

0 comments on commit 7b9e7e3

Please sign in to comment.