INNER CODE UNIT · Go
resolveVersion
werf/nelm · scripts/denolock/main.go:263
func resolveVersion(opts options) (string, error) {
if opts.version != "" {
return strings.TrimPrefix(opts.version, "v"), nil
}
lock, err := readLock(opts.outputPath)
if err != nil {
return "", fmt.Errorf("%w, and no -version given to pin instead", err)
}
return lock.Version, nil
}
// readLock reads the file in the working tree, not the copy embedded into this binary.
func readLock(path string) (*denolock.Lock, error) {
lockBytes, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("read %s: %w", path, err)