Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cmd/pkg/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ package pkg

import (
"fmt"
"os"
"os/exec"
"strings"

"go.trai.ch/gecro/config"
"go.trai.ch/gecro/internal/generator"
Expand Down Expand Up @@ -42,10 +45,29 @@ var newCmd = &cobra.Command{
return fmt.Errorf("failed generating new package: %w", err)
}

if err := runPostCreateHook(config.DryRun); err != nil {
return err
}

return nil
},
}

func runPostCreateHook(dryRun bool) error {
if dryRun {
return nil
}

command := "bazel"
args := []string{"run", "//:gazelle"}

fmt.Printf("Running post-create hook: %s %s\n", command, strings.Join(args, " "))
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func init() {
PkgCmd.AddCommand(newCmd)

Expand Down
22 changes: 22 additions & 0 deletions cmd/service/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ package service

import (
"fmt"
"os"
"os/exec"
"strings"

"go.trai.ch/gecro/config"
"go.trai.ch/gecro/internal/generator"
Expand Down Expand Up @@ -39,10 +42,29 @@ var newCmd = &cobra.Command{
return fmt.Errorf("failed generating new service: %w", err)
}

if err := runPostCreateHook(config.DryRun); err != nil {
return err
}

return nil
},
}

func runPostCreateHook(dryRun bool) error {
if dryRun {
return nil
}

command := "bazel"
args := []string{"run", "//:gazelle"}

fmt.Printf("Running post-create hook: %s %s\n", command, strings.Join(args, " "))
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func init() {
ServiceCmd.AddCommand(newCmd)

Expand Down