<commit_before>package build

import (
	"fmt"
	"github.com/fatih/color"
	"github.com/servehub/utils"
	"log"
	"os"
	"os/exec"
	"strings"

	"github.com/servehub/serve/manifest"
)

func init() {
	manifest.PluginRegestry.Add("build.monorepo", buildMonorepo{})
}

type buildMonorepo struct{}

func (p buildMonorepo) Run(data manifest.Manifest) error {
	lernaCmd := fmt.Sprintf(data.GetString("command"), data.GetString("lerna-image"))

	log.Println(color.YellowString("> %s", lernaCmd))

	out, err := exec.Command("/bin/bash", "-ec", lernaCmd).CombinedOutput()
	if err != nil {
		log.Println(color.RedString("%s", out))
		return err
	}

	lines := strings.Split(strings.TrimSpace(string(out)), "\n")
	pwd, _ := os.Getwd()

	for i, line := range lines {
		if i != 0 {
			dir := pwd + "/" + strings.TrimPrefix(line, "/src/")

			if _, err := os.Stat(dir + "/manifest.yml"); !os.IsNotExist(err) {
				log.Println(color.BlueString("%s was changed", dir))

				if err := utils.RunCmd("cd %s && serve gocd.pipeline.run --branch=%s --commit=%s", dir, data.GetString("branch"), data.GetString("commit")); err != nil {
					log.Println(color.RedString("%s", err))
					return err
				}
			}
		}
	}

	return nil
}<commit_msg>fix lerna runner<commit_after>package build

import (
	"fmt"
	"github.com/fatih/color"
	"github.com/servehub/utils"
	"log"
	"os"
	"os/exec"
	"strings"

	"github.com/servehub/serve/manifest"
)

func init() {
	manifest.PluginRegestry.Add("build.monorepo", buildMonorepo{})
}

type buildMonorepo struct{}

func (p buildMonorepo) Run(data manifest.Manifest) error {
	lernaCmd := fmt.Sprintf(data.GetString("command"), data.GetString("lerna-image"))

	log.Println(color.YellowString("> %s", lernaCmd))

	out, err := exec.Command("/bin/bash", "-ec", lernaCmd).CombinedOutput()
	if err != nil {
		log.Println(color.RedString("%s", out))
		return err
	}

	log.Println(color.YellowString("<<< %s", string(out)))

	lines := strings.Split(strings.TrimSpace(string(out)), "\n")
	pwd, _ := os.Getwd()

	for _, line := range lines {
		if strings.HasPrefix(line, "/src/") {
			dir := pwd + "/" + strings.TrimPrefix(line, "/src/")

			if _, err := os.Stat(dir + "/manifest.yml"); !os.IsNotExist(err) {
				log.Println(color.BlueString("%s was changed", dir))

				if err := utils.RunCmd("cd %s && serve gocd.pipeline.run --branch=%s --commit=%s", dir, data.GetString("branch"), data.GetString("commit")); err != nil {
					log.Println(color.RedString("%s", err))
					return err
				}
			}
		}
	}

	return nil
}
{'fraction_non_alphanumeric': 0.19608626198083068, 'fraction_numerical': 0.00039936102236421724, 'mean_word_length': 4.030120481927711, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5158387', 'n_tokens_mistral': 1007, 'n_tokens_neox': 933, 'n_words': 178}