예제 #1
0
func (s *ToolsLoader) Run(ctx *types.Context) error {
	folders := ctx.ToolsFolders

	tools := []*types.Tool{}

	for _, folder := range folders {
		builtinToolsVersionsFile, err := findBuiltinToolsVersionsFile(folder)
		if err != nil {
			return i18n.WrapError(err)
		}
		if builtinToolsVersionsFile != constants.EMPTY_STRING {
			err = loadToolsFrom(&tools, builtinToolsVersionsFile)
			if err != nil {
				return i18n.WrapError(err)
			}
		} else {
			subfolders, err := collectAllToolsFolders(folder)
			if err != nil {
				return i18n.WrapError(err)
			}

			for _, subfolder := range subfolders {
				err = loadToolsFromFolderStructure(&tools, subfolder)
				if err != nil {
					return i18n.WrapError(err)
				}
			}
		}
	}

	ctx.Tools = tools

	return nil
}