check

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckCmd = &cobra.Command{
	Use:   "check [recipe-dir]",
	Short: "check a directory of recipes",
	Long: `
The "check" subcommand checks that all recipes in a directory are valid.`,
	Example: `webman check ~/repos/webman-pkgs/`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			cmd.Help()
			os.Exit(0)
		}
		recipeDir, err := filepath.Abs(args[0])
		utils.WebmanRecipeDir = recipeDir
		if err != nil {
			panic(err)
		}
		entries, err := os.ReadDir(filepath.Join(recipeDir, "pkgs"))
		if err != nil {
			panic(err)
		} else {
			var wg sync.WaitGroup
			success := true
			wg.Add(len(entries))
			for _, recipe := range entries {
				recipe := recipe

				go func() {
					recipeName := recipe.Name()
					pkg := strings.ReplaceAll(recipeName, utils.PkgRecipeExt, "")
					err := CheckPkgConfig(pkg)
					if err != nil {
						var lintErr schema.ResultErrors
						if errors.As(err, &lintErr) {
							for _, le := range lintErr {
								color.Red("%s: %s", color.YellowString(recipeName), color.RedString("%s: %s", le.Field(), le.Description()))
							}
						} else {
							color.Red("%s: %s", color.YellowString(recipeName), color.RedString("%v", err))
						}
						success = false
					}
					wg.Done()
				}()
			}
			wg.Wait()
			if !success {
				color.Magenta("Not all packages are valid!")
				os.Exit(1)
			}
			color.Green("All packages are valid!")
		}
	},
}

CheckCmd represents the remove command

Functions

func CheckPkgConfig

func CheckPkgConfig(pkg string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL