fix(configcmd): config create --output - prints the template to stdout

It wrote a file named "-" in the working directory instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-11-28 12:33:03 +01:00
1 parent 5d141c7cef
commit 975340b5f7
2 files changed
+28 -3

No files matched your search

+21
View File
@@ -190,6 +190,27 @@ func TestCreateExplicitAndOutput(t *testing.T) {
}
}
// --output - prints the template and writes no file (not one named "-").
func TestCreateOutputStdout(t *testing.T) {
root := t.TempDir()
s := testSpec(root)
work := filepath.Join(root, "work")
if err := os.MkdirAll(work, 0o755); err != nil {
t.Fatal(err)
}
t.Chdir(work)
code, out, errOut := run(t, s, "", "create", "--full", "--output", "-")
if code != ExitOK || out != fullTemplate || errOut != "" {
t.Fatalf("create --output -: exit %d, stdout %q, stderr %q", code, out, errOut)
}
if _, err := os.Stat(filepath.Join(work, "-")); !errors.Is(err, os.ErrNotExist) {
t.Errorf("create --output - wrote a file named \"-\": %v", err)
}
if code, out, _ := run(t, s, "", "create", "--output=-"); code != ExitOK || out != minimalTemplate {
t.Errorf("create --output=-: exit %d, stdout %q", code, out)
}
}
func TestValidate(t *testing.T) {
root := t.TempDir()
s := testSpec(root)