mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-02-05 21:45:39 +00:00
* 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
33 lines
1.0 KiB
Go
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
|
|
}
|