Skip to content

Commit

Permalink
fix: rm the generation of kcl.mod when compile virtual package
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <zongzhe1024@163.com>
  • Loading branch information
zong-zhe committed Aug 9, 2024
1 parent a110766 commit bbd3a1c
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions pkg/client/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ func (vpv *VirtualPkgVisitor) Visit(s *downloader.Source, v visitFunc) error {
// After the visitFunc is executed, clean the virtual kcl.mod file.
defer func() error {
vKclModLockPath := filepath.Join(sourcePath, constants.KCL_MOD_LOCK)
if utils.DirExists(vKclModPath) {
err := os.RemoveAll(vKclModPath)
if err != nil {
return err
}
}
if utils.DirExists(vKclModLockPath) {
err := os.RemoveAll(vKclModLockPath)
if err != nil {
Expand All @@ -97,28 +91,16 @@ func (vpv *VirtualPkgVisitor) Visit(s *downloader.Source, v visitFunc) error {
}
return nil
}()
initOpts := opt.InitOptions{
Name: "vPkg_" + uuid.New().String(),
InitPath: sourcePath,
}

modfile := pkg.NewModFile(&initOpts)
logWriter := vpv.kpmcli.GetLogWriter()
vpv.kpmcli.SetLogWriter(nil)
err = vpv.kpmcli.createIfNotExist(modfile.GetModFilePath(), modfile.StoreModFile)
if err != nil {
return err
}
vpv.kpmcli.SetLogWriter(logWriter)
}

kclPkg, err := vpv.kpmcli.LoadPkgFromPath(sourcePath)
if err != nil {
return err
initOpts := opt.InitOptions{
Name: "vPkg_" + uuid.New().String(),
InitPath: sourcePath,
}

kpkg := pkg.NewKclPkg(&initOpts)
// If the required files are present, proceed with the visitFunc
return v(kclPkg)
return v(&kpkg)
}

// RemoteVisitor is the visitor for visiting a remote package.
Expand Down

0 comments on commit bbd3a1c

Please sign in to comment.