Files
gh-action-readme/internal/helpers/analyzer.go
Ismo Vuorinen 7f80105ff5 feat: go 1.25.5, dependency updates, renamed internal/errors (#129)
* feat: rename internal/errors to internal/apperrors

* fix(tests): clear env values before using in tests

* feat: rename internal/errors to internal/apperrors

* chore(deps): update go and all dependencies

* chore: remove renovate from pre-commit, formatting

* chore: sonarcloud fixes

* feat: consolidate constants to appconstants/constants.go

* chore: sonarcloud fixes

* feat: simplification, deduplication, test utils

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: clean up

* fix: config discovery, const deduplication

* chore: fixes
2026-01-01 23:17:29 +02:00

33 lines
1.0 KiB
Go

// Package helpers provides helper functions used across the application.
package helpers
import (
"github.com/ivuorinen/gh-action-readme/appconstants"
"github.com/ivuorinen/gh-action-readme/internal"
"github.com/ivuorinen/gh-action-readme/internal/dependencies"
)
// CreateAnalyzer creates a dependency analyzer with standardized error handling.
// Returns nil if creation fails (error already logged to output).
func CreateAnalyzer(generator *internal.Generator, output *internal.ColoredOutput) *dependencies.Analyzer {
analyzer, err := generator.CreateDependencyAnalyzer()
if err != nil {
output.Warning(appconstants.ErrCouldNotCreateDependencyAnalyzer, err)
return nil
}
return analyzer
}
// CreateAnalyzerOrExit creates a dependency analyzer or exits on failure.
func CreateAnalyzerOrExit(generator *internal.Generator, output *internal.ColoredOutput) *dependencies.Analyzer {
analyzer := CreateAnalyzer(generator, output)
if analyzer == nil {
// Error already logged, just exit
return nil
}
return analyzer
}