Only write .bazelrc file if it is not empty
This commit is contained in:
parent
158caeb0c7
commit
6a0205c72b
|
@ -205,6 +205,7 @@ func mustWriteLanguageExampleBazelrcFile(dir string, lang *Language, rule *Rule)
|
|||
out.w("#")
|
||||
}
|
||||
out.w("%s --%s=%s", f.Category, f.Name, f.Value)
|
||||
out.ln()
|
||||
}
|
||||
for _, f := range rule.Flags {
|
||||
if f.Description != "" {
|
||||
|
@ -213,9 +214,18 @@ func mustWriteLanguageExampleBazelrcFile(dir string, lang *Language, rule *Rule)
|
|||
out.w("#")
|
||||
}
|
||||
out.w("%s --%s=%s", f.Category, f.Name, f.Value)
|
||||
out.ln()
|
||||
}
|
||||
|
||||
// Only write a .bazelrc if it's not empty
|
||||
if len(out.lines) > 0 {
|
||||
out.MustWrite(filepath.Join(dir, ".bazelrc"))
|
||||
} else {
|
||||
e := os.Remove(filepath.Join(dir, ".bazelrc"))
|
||||
if e != nil {
|
||||
log.Fatal(e)
|
||||
}
|
||||
}
|
||||
out.ln()
|
||||
out.MustWrite(filepath.Join(dir, ".bazelrc"))
|
||||
}
|
||||
|
||||
func mustWriteLanguageDefs(dir string, lang *Language) {
|
||||
|
|
Loading…
Reference in New Issue