Centralize managed state targets
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const stateFileName = ".distributor.json"
|
||||
const StateFileName = ".distributor.json"
|
||||
|
||||
func ValidatePath(value string) error {
|
||||
if value == "" {
|
||||
@@ -37,9 +37,29 @@ func Join(base, child string) (string, error) {
|
||||
|
||||
func StatePath(bundlePath string) (string, error) {
|
||||
if bundlePath == "" {
|
||||
return stateFileName, nil
|
||||
return StateFileName, nil
|
||||
}
|
||||
return Join(bundlePath, stateFileName)
|
||||
return Join(bundlePath, StateFileName)
|
||||
}
|
||||
|
||||
func ManagedBundleTargets(bundlePath string, managedOutputPaths []string) ([]string, error) {
|
||||
if err := ValidatePrefix(bundlePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
targets := make([]string, 0, len(managedOutputPaths)+1)
|
||||
for _, outputPath := range managedOutputPaths {
|
||||
target, err := Join(bundlePath, outputPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
targets = append(targets, target)
|
||||
}
|
||||
statePath, err := StatePath(bundlePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
targets = append(targets, statePath)
|
||||
return targets, nil
|
||||
}
|
||||
|
||||
func SortEntries(entries []Entry) {
|
||||
|
||||
Reference in New Issue
Block a user