func()

in internal/core/component.go [153:176]


func (c *Component) ExecuteHook(hook string) (err error) {
	if c.Hooks[hook] == nil {
		return nil
	}

	for _, command := range c.Hooks[hook] {
		logger.Info(emoji.Sprintf(":fishing_pole_and_fish: Executing command in hook '%s' for component '%s': %s", hook, c.Name, command))
		if len(command) != 0 {
			cmd := exec.Command("sh", "-c", command)
			cmd.Dir = c.PhysicalPath
			output, err := cmd.CombinedOutput()
			if err != nil {
				logger.Error(emoji.Sprintf(":no_entry_sign: Error occurred in hook '%s' for component '%s'\n%s: %s", hook, c.Name, err, output))
				return err
			}
			if len(output) > 0 {
				outstring := emoji.Sprintf(":mag_right: Completed hook '%s' for component '%s':\n%s", hook, c.Name, output)
				logger.Trace(strings.TrimSpace(outstring))
			}
		}
	}

	return nil
}