@@ -11,6 +11,7 @@ import (
11
11
12
12
"github.com/acarl005/stripansi"
13
13
"github.com/pkg/errors"
14
+ "kcl-lang.io/cli/pkg/fs"
14
15
"kcl-lang.io/kcl-go/pkg/kcl"
15
16
"kcl-lang.io/kpm/pkg/api"
16
17
"kcl-lang.io/kpm/pkg/client"
@@ -88,7 +89,7 @@ func (o *RunOptions) Run() error {
88
89
}
89
90
if entry .IsEmpty () {
90
91
// kcl compiles the current package under '$pwd'.
91
- if _ , found := api .GetKclPackage (pwd ); found == nil {
92
+ if _ , e := api .GetKclPackage (pwd ); e == nil {
92
93
opts .SetPkgPath (pwd )
93
94
result , err = cli .CompileWithOpts (opts )
94
95
} else {
@@ -112,8 +113,18 @@ func (o *RunOptions) Run() error {
112
113
}
113
114
transformedEntries = append (transformedEntries , entry )
114
115
}
115
- opts .SetEntries (transformedEntries )
116
- opts .SetPkgPath (entry .PackageSource ())
116
+ // Maybe a single KCL module folder, use the kcl.mod entry profile to run.
117
+ if pkg , e := api .GetKclPackage (transformedEntries [0 ]); e == nil && fs .IsDir (transformedEntries [0 ]) {
118
+ entries := pkg .GetPkgProfile ().Entries
119
+ if len (entries ) > 0 {
120
+ opts .SetEntries (entries )
121
+ }
122
+ opts .SetPkgPath (transformedEntries [0 ])
123
+ } else {
124
+ // Multiple entries with the kcl.mod file and deps.
125
+ opts .SetEntries (transformedEntries )
126
+ opts .SetPkgPath (entry .PackageSource ())
127
+ }
117
128
result , err = cli .CompileWithOpts (opts )
118
129
} else if entry .IsTar () {
119
130
// kcl compiles the package from the kcl package tar.
0 commit comments