cosmetic: readability

Test: run `m nothing` and `m nothing --empty_ninja_file`
Bug: NA
Change-Id: I6fd81667ea2d636139ae38bc36315f8710b72c25
This commit is contained in:
Usta Shrestha 2023-02-17 17:52:47 -05:00 committed by Usta (Tsering) Shrestha
parent 26e44b7b78
commit ce85ecb176

View file

@ -139,9 +139,8 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
if err := os.WriteFile(joinPath(ctx.SrcDir(), args.OutFile), []byte(nil), outFilePermissions); err != nil { if err := os.WriteFile(joinPath(ctx.SrcDir(), args.OutFile), []byte(nil), outFilePermissions); err != nil {
fatalf("error writing empty Ninja file: %s", err) fatalf("error writing empty Ninja file: %s", err)
} }
} out = io.Discard.(io.StringWriter)
} else {
if !args.EmptyNinjaFile {
f, err := os.OpenFile(joinPath(ctx.SrcDir(), args.OutFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions) f, err := os.OpenFile(joinPath(ctx.SrcDir(), args.OutFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions)
if err != nil { if err != nil {
fatalf("error opening Ninja file: %s", err) fatalf("error opening Ninja file: %s", err)
@ -149,8 +148,6 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
defer f.Close() defer f.Close()
buf = bufio.NewWriterSize(f, 16*1024*1024) buf = bufio.NewWriterSize(f, 16*1024*1024)
out = buf out = buf
} else {
out = io.Discard.(io.StringWriter)
} }
if err := ctx.WriteBuildFile(out); err != nil { if err := ctx.WriteBuildFile(out); err != nil {