func()

in internal/core/component.go [203:232]


func (c *Component) InstallComponent(componentPath string) (err error) {
	if c.ComponentType == "component" {
		if c.Method == "git" {
			// ensure `components` dir exists
			componentsPath := path.Join(componentPath, "components")
			if err := os.MkdirAll(componentsPath, 0777); err != nil {
				return err
			}

			// delete the subcomponent if previously installed
			subcomponentPath := path.Join(componentPath, c.RelativePathTo())
			if err = os.RemoveAll(subcomponentPath); err != nil {
				return err
			}

			logger.Info(emoji.Sprintf(":helicopter: Installing component '%s' with git from '%s'", c.Name, c.Source))
			cloneOpts := &git.CloneOpts{
				URL:    c.Source,
				SHA:    c.Version,
				Branch: c.Branch,
				Into:   subcomponentPath}
			if err = git.Clone(cloneOpts); err != nil {
				return err
			}
			return nil
		}
	}

	return nil
}