cmd/ent: Add check that model file doesn't already exist on ent init (#2307)

Previously if you run  it would overwrite an existing file  if that already existed. Now  checks if that file already exists, and returns an error if so.
This commit is contained in:
Andy Day
2022-02-02 15:44:04 -08:00
committed by GitHub
parent 0e49dd1d9f
commit 2e906bffa2
2 changed files with 11 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ func TestCmd(t *testing.T) {
stderr := bytes.NewBuffer(nil)
cmd.Stderr = stderr
require.NoError(t, cmd.Run(), stderr.String())
cmd = exec.Command("go", "run", "entgo.io/ent/cmd/ent", "init", "User")
require.Error(t, cmd.Run())
_, err := os.Stat("ent/generate.go")
require.NoError(t, err)