Skip to content

Commit

Permalink
bugfix: gen: file/shadow removal, mod: undo symlinks / error in dirha…
Browse files Browse the repository at this point in the history
…sh calc
  • Loading branch information
verdverm committed Oct 29, 2020
1 parent e912d9a commit b8b7317
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/gen/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (F *File) RenderTemplate() error {

err = F.FormatRendered()
if err != nil {
fmt.Println("---- Rendering error for", F.TemplateName, F.Filepath)
fmt.Printf("---- Rendering error for template: %q output: %q content:\n", F.TemplateName, F.Filepath)
fmt.Println(string(F.RenderContent))
fmt.Println("----")
return err
Expand Down
2 changes: 1 addition & 1 deletion lib/mod/langs/cue.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cue: {
SumFile: string | * "cue.sums"
ModsDir: string | * "cue.mod/pkg"
MappingFile: string | * "cue.mod/modules.txt"
SymlinkLocalReplaces: bool | *true,
SymlinkLocalReplaces?: bool,
InitTemplates: {...} | *{
"cue.mod/module.cue": """
module: "{{ .Module }}"
Expand Down
14 changes: 10 additions & 4 deletions lib/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ func (R *Runtime) RunGenerators() []error {
errs = append(errs, errsG...)
continue
}

}


return errs
}

Expand Down Expand Up @@ -338,23 +338,28 @@ func (R *Runtime) WriteOutput() []error {
// Cleanup File & Shadow
// fmt.Println("Clean Shadow", G.Name)
for f, _ := range G.Shadow {
// fmt.Println(" -", G.Name, f, strings.TrimPrefix(f, G.Name + "/"))
err := os.Remove(f)
genFilename := strings.TrimPrefix(f, G.Name + "/")
shadowFilename := path.Join(gen.SHADOW_DIR, f)
fmt.Println(" -", G.Name, f, genFilename, shadowFilename)

err := os.Remove(genFilename)
if err != nil {
if strings.Contains(err.Error(), "no such file or directory") {
continue
}
errs = append(errs, err)
continue
}
err = os.Remove(path.Join(gen.SHADOW_DIR, f))

err = os.Remove(shadowFilename)
if err != nil {
if strings.Contains(err.Error(), "no such file or directory") {
continue
}
errs = append(errs, err)
continue
}

G.Stats.NumDeleted += 1
}

Expand All @@ -363,6 +368,7 @@ func (R *Runtime) WriteOutput() []error {

}

// TODO, remove this? do we even have global shadow files? The section to load them is commented out
// Clean global shadow, incase any generators were removed
for f, _ := range R.Shadow {
// deal with leading shadow dir name?
Expand Down

0 comments on commit b8b7317

Please sign in to comment.