MCPcopy Index your code
hub / github.com/conventionalcommit/commitlint / newHookCmd

Function newHookCmd

internal/cmd/cmd.go:177–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175}
176
177func newHookCmd() *cli.Command {
178 return &cli.Command{
179 Name: "hook",
180 Usage: "Create the commit-msg git hook",
181 Flags: []cli.Flag{
182 &cli.BoolFlag{
183 Name: "replace",
184 Aliases: []string{"r"},
185 Usage: "Overwrite existing hook files",
186 },
187 &cli.StringFlag{
188 Name: "hookspath",
189 Aliases: []string{"p"},
190 Usage: "Where to write hook files (default: .commitlint/hooks)",
191 },
192 },
193 Action: func(ctx *cli.Context) error {
194 isReplace := ctx.Bool("replace")
195 hooksPath := ctx.String("hookspath")
196 err := hookCreate(hooksPath, isReplace)
197 if err != nil {
198 if isHookExists(err) {
199 fmt.Println("hook files already exist")
200 fmt.Println("use --replace to overwrite them")
201 return nil
202 }
203 return err
204 }
205 fmt.Println("hooks created")
206 return nil
207 },
208 }
209}
210
211func newRemoveCmd() *cli.Command {
212 return &cli.Command{

Callers 1

newCliAppFunction · 0.85

Calls 3

hookCreateFunction · 0.85
isHookExistsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected