MCPcopy Create free account
hub / github.com/dirk/quickhook / installShim

Function installShim

install.go:113–139  ·  view source on GitHub ↗
(repo *repo.Repo, shimPath, quickhook, hook string, prompt bool)

Source from the content-addressed store, hash-verified

111}
112
113func installShim(repo *repo.Repo, shimPath, quickhook, hook string, prompt bool) error {
114 command, err := shimCommandForHook(quickhook, hook)
115 if err != nil {
116 return err
117 }
118
119 lines := []string{
120 "#!/bin/sh",
121 command,
122 "", // So we get a trailing newline when we join
123 }
124
125 file, err := os.Create(shimPath)
126 if err != nil {
127 return err
128 }
129 defer file.Close()
130
131 err = os.Chmod(shimPath, 0755)
132 if err != nil {
133 return err
134 }
135
136 file.WriteString(strings.Join(lines, "\n"))
137
138 return nil
139}
140
141func shimCommandForHook(quickhook, hook string) (string, error) {
142 var args string

Callers 1

installFunction · 0.85

Calls 1

shimCommandForHookFunction · 0.85

Tested by

no test coverage detected