From b86884da9b01ed458394340cd9b3902dc6b193ef Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Sun, 19 May 2024 21:31:56 +0530 Subject: [PATCH] fix: rename in kpm add Signed-off-by: Asish Kumar --- pkg/client/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index bc665a00..e8b8285d 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -631,10 +631,12 @@ func (c *KpmClient) AddDepWithOpts(kclPkg *pkg.KclPkg, opt *opt.AddOptions) (*pk } // 3. update the kcl.mod and kcl.mod.lock. - tempDeps := kclPkg.ModFile.Dependencies.Deps[d.Name] - tempDeps.Name = opt.NewPkgName - kclPkg.ModFile.Dependencies.Deps[d.Name] = tempDeps - + if opt.NewPkgName != "" { + tempDeps := kclPkg.ModFile.Dependencies.Deps[d.Name] + tempDeps.Name = opt.NewPkgName + kclPkg.ModFile.Dependencies.Deps[d.Name] = tempDeps + } + err = kclPkg.UpdateModAndLockFile() if err != nil { return nil, err