MCPcopy Create free account
hub / github.com/cli/cli / InstallLocal

Method InstallLocal

pkg/cmd/extension/manager.go:214–242  ·  view source on GitHub ↗
(dir string)

Source from the content-addressed store, hash-verified

212}
213
214func (m *Manager) InstallLocal(dir string) error {
215 name := filepath.Base(dir)
216 if err := m.cleanExtensionUpdateDir(name); err != nil {
217 return err
218 }
219 targetLink := filepath.Join(m.installDir(), name)
220
221 if err := os.MkdirAll(filepath.Dir(targetLink), 0755); err != nil {
222 return err
223 }
224 if err := makeSymlink(dir, targetLink); err != nil {
225 return err
226 }
227
228 // Check if an executable of the same name exists in the target directory.
229 // An error here doesn't indicate a failed extension installation, but
230 // it does indicate that the user will not be able to run the extension until
231 // the executable file is built or created manually somehow.
232 if _, err := os.Stat(filepath.Join(dir, name)); err != nil {
233 if os.IsNotExist(err) {
234 return &ErrExtensionExecutableNotFound{
235 Dir: dir,
236 Name: name,
237 }
238 }
239 return err
240 }
241 return nil
242}
243
244type binManifest struct {
245 Owner string

Callers

nothing calls this directly

Calls 5

installDirMethod · 0.95
BaseMethod · 0.80
JoinMethod · 0.80
makeSymlinkFunction · 0.70

Tested by

no test coverage detected