Skip to content

Commit 84031c1

Browse files
davemooreuwstjholm
authored andcommitted
fix: relative handler path and get runtime correctly
1 parent 8818a22 commit 84031c1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/provider/run/function.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func (f *Function) Name() string {
2424
return strings.Replace(filepath.Base(f.handler), filepath.Ext(f.handler), "", 1)
2525
}
2626

27+
func runTimeFromHandler(handler string) string {
28+
return strings.Replace(filepath.Ext(handler), ".", "", -1)
29+
}
30+
2731
func (f *Function) Start() error {
2832
hostConfig := &container.HostConfig{
2933
AutoRemove: true,
@@ -74,10 +78,9 @@ type FunctionOpts struct {
7478
}
7579

7680
func NewFunction(opts FunctionOpts) (*Function, error) {
77-
7881
var runtime Runtime = RuntimeTypescript
7982

80-
switch Runtime(filepath.Ext(opts.Handler)) {
83+
switch Runtime(runTimeFromHandler(opts.Handler)) {
8184
case RuntimeTypescript:
8285
runtime = RuntimeTypescript
8386
case RuntimeJavascript:
@@ -102,9 +105,11 @@ func FunctionsFromHandlers(runCtx string, handlers []string) ([]*Function, error
102105
}
103106

104107
for _, h := range handlers {
108+
relativeHandlerPath, _ := filepath.Rel(runCtx, h)
109+
105110
if f, err := NewFunction(FunctionOpts{
106111
RunCtx: runCtx,
107-
Handler: h,
112+
Handler: relativeHandlerPath,
108113
ContainerEngine: ce,
109114
}); err != nil {
110115
return nil, err

0 commit comments

Comments
 (0)