You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
fix: nfpm deprecation on nfpm check (#3087)
closes #3067 Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4cf566be44
commit
f812d1b920
@@ -4,9 +4,7 @@ package deprecate
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
@@ -17,24 +15,6 @@ import (
|
||||
|
||||
const baseURL = "https://goreleaser.com/deprecations#"
|
||||
|
||||
// NewWriter return a io.Writer that notices deprecations.
|
||||
func NewWriter(ctx *context.Context) io.Writer {
|
||||
return &writer{ctx: ctx}
|
||||
}
|
||||
|
||||
type writer struct {
|
||||
ctx *context.Context
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
func (w *writer) Write(p []byte) (n int, err error) {
|
||||
w.once.Do(func() {
|
||||
w.ctx.Deprecated = true
|
||||
})
|
||||
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf("DEPRECATED: " + strings.TrimSuffix(string(p), "\n")))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// Notice warns the user about the deprecation of the given property.
|
||||
func Notice(ctx *context.Context, property string) {
|
||||
NoticeCustom(ctx, property, "`{{ .Property }}` should not be used anymore, check {{ .URL }} for more info")
|
||||
|
||||
@@ -42,19 +42,3 @@ func TestNoticeCustom(t *testing.T) {
|
||||
|
||||
golden.RequireEqualTxt(t, w.Bytes())
|
||||
}
|
||||
|
||||
func TestWriter(t *testing.T) {
|
||||
var w bytes.Buffer
|
||||
|
||||
color.NoColor = true
|
||||
log.SetHandler(cli.New(&w))
|
||||
|
||||
log.Info("first")
|
||||
ctx := context.New(config.Project{})
|
||||
ww := NewWriter(ctx)
|
||||
_, err := ww.Write([]byte("foo bar\n"))
|
||||
require.NoError(t, err)
|
||||
require.True(t, ctx.Deprecated)
|
||||
|
||||
golden.RequireEqualTxt(t, w.Bytes())
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
• first
|
||||
• DEPRECATED: foo bar
|
||||
@@ -3,6 +3,7 @@ package nfpm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -54,10 +55,16 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
if fpm.FileNameTemplate == "" {
|
||||
fpm.FileNameTemplate = defaultNameTemplate
|
||||
}
|
||||
if len(fpm.EmptyFolders) > 0 {
|
||||
deprecate.Notice(ctx, "nfpms.empty_folders")
|
||||
}
|
||||
if fpm.Maintainer == "" {
|
||||
deprecate.Notice(ctx, "nfpms.maintainer")
|
||||
}
|
||||
ids.Inc(fpm.ID)
|
||||
}
|
||||
|
||||
deprecation.Noticer = deprecate.NewWriter(ctx)
|
||||
deprecation.Noticer = io.Discard
|
||||
return ids.Validate()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user