From 71b2f16adceb55f076db482d9e4efd60f9f4411e Mon Sep 17 00:00:00 2001 From: kanno <812137533@qq.com> Date: Fri, 16 Jun 2023 15:27:58 +0800 Subject: [PATCH] feat: delete sourcee will use preset alias --- internal/action/action.go | 11 +++++++++++ internal/source/conf.go | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/action/action.go b/internal/action/action.go index 3edad09..f1a2607 100644 --- a/internal/action/action.go +++ b/internal/action/action.go @@ -124,6 +124,17 @@ func (action *actionImpl) Drop() int { }) return 1 } + // Set npm as default choose + ok := action.conf.SetCurrentPath(source.DefaultKey[source.Npm]) + if ok { + err := action.fs.OuputFile(action.conf.ConfPath, []byte(action.conf.GetCurrentConf())) + if err != nil { + logger.PrintTextWithColor(os.Stderr, func(c logger.Colors) string { + return fmt.Sprintf("%s%s%s\n", c.Red, err, c.Reset) + }) + return 1 + } + } logger.PrintTextWithColor(os.Stdout, func(c logger.Colors) string { return fmt.Sprintf("%s%s%s\n", c.Green, "remove registry success", c.Reset) }) diff --git a/internal/source/conf.go b/internal/source/conf.go index 8a97026..b5a88ed 100644 --- a/internal/source/conf.go +++ b/internal/source/conf.go @@ -111,7 +111,11 @@ func NewGrmConf() *GrmConfig { func (g *GrmConfig) ListAllPath() { aliases, files := g.scanner() list := make([]string, 0, len(aliases)+len(SourceToString)) - list = append(list, SourceToString...) + for _, s := range SourceToString { + if s != System.String() { + list = append(list, s) + } + } list = append(list, aliases...) g.files = files g.aliases = aliases