diff --git a/cmd/createttp.go b/cmd/createttp.go index b3f062b7..3e093131 100644 --- a/cmd/createttp.go +++ b/cmd/createttp.go @@ -21,12 +21,13 @@ package cmd import ( "fmt" - "text/template" - "github.com/facebookincubator/ttpforge/pkg/platforms" "github.com/google/uuid" "github.com/spf13/afero" "github.com/spf13/cobra" + "os" + "path/filepath" + "text/template" ) const ttpTemplate = `--- @@ -74,6 +75,12 @@ func buildCreateTTPCommand() *cobra.Command { return fmt.Errorf("%v already exists", newTTPFilePath) } + // create the directory for the new TTP file, if it doesn't already exist + err = fsys.MkdirAll(filepath.Dir(newTTPFilePath), os.ModePerm) + if err != nil { + return fmt.Errorf("failed to create directory for new TTP file: %w", err) + } + // create the new TTP file with afero f, err := fsys.Create(newTTPFilePath) if err != nil {