Skip to content

Commit

Permalink
Merge pull request #97 from nitrictech/fix/windows-path
Browse files Browse the repository at this point in the history
fix: use filepath to get dev image path
  • Loading branch information
davemooreuws authored Feb 24, 2022
2 parents 4462649 + 65d2696 commit 1fd5d71
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ GOLANGCI_LINT ?= GOLANGCI_LINT_CACHE=$(GOLANGCI_LINT_CACHE) go run github.com/go
build: generate
CGO_ENABLED=0 go build -o bin/nitric ./pkg/cmd/

.PHONY: build-windows
build-windows: generate
go build -o bin/nitric.exe ./pkg/cmd/

.PHONY: generate
generate:
@go run github.com/golang/mock/mockgen github.com/nitrictech/cli/pkg/containerengine ContainerEngine > mocks/mock_containerengine/mock_containerengine.go
Expand Down
10 changes: 5 additions & 5 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package build
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"

"github.com/nitrictech/cli/pkg/containerengine"
Expand Down Expand Up @@ -56,15 +56,15 @@ func Create(s *stack.Stack, t *target.Target) error {
fh.Close()

buildArgs := map[string]string{"PROVIDER": t.Provider}
err = cr.Build(path.Base(fh.Name()), s.Dir, f.ImageTagName(s, t.Provider), buildArgs)
err = cr.Build(filepath.Base(fh.Name()), s.Dir, f.ImageTagName(s, t.Provider), buildArgs)
if err != nil {
return err
}
}

for _, c := range s.Containers {
buildArgs := map[string]string{"PROVIDER": t.Provider}
err := cr.Build(path.Join(s.Dir, c.Dockerfile), s.Dir, c.ImageTagName(s, t.Provider), buildArgs)
err := cr.Build(filepath.Join(s.Dir, c.Dockerfile), s.Dir, c.ImageTagName(s, t.Provider), buildArgs)
if err != nil {
return err
}
Expand All @@ -84,7 +84,7 @@ func CreateBaseDev(s *stack.Stack) error {
if err != nil {
return err
}
lang := strings.Replace(path.Ext(f.Handler), ".", "", 1)
lang := strings.Replace(filepath.Ext(f.Handler), ".", "", 1)
_, ok := imagesToBuild[lang]
if ok {
continue
Expand All @@ -104,7 +104,7 @@ func CreateBaseDev(s *stack.Stack) error {
return err
}

if err := ce.Build(path.Base(f.Name()), s.Dir, rt.DevImageName(), map[string]string{}); err != nil {
if err := ce.Build(filepath.Base(f.Name()), s.Dir, rt.DevImageName(), map[string]string{}); err != nil {
return err
}
imagesToBuild[lang] = rt.DevImageName()
Expand Down
4 changes: 2 additions & 2 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"net"
"os"
"path"
"path/filepath"
"time"

"github.com/nitrictech/cli/pkg/utils"
Expand Down Expand Up @@ -60,7 +60,7 @@ func NewLocalServices(stackName, stackPath string) LocalServices {
stackName: stackName,
stackPath: stackPath,
status: &LocalServicesStatus{
RunDir: path.Join(utils.NitricRunDir(), stackName),
RunDir: filepath.Join(utils.NitricRunDir(), stackName),
GatewayAddress: nitric_utils.GetEnv("GATEWAY_ADDRESS", ":9001"),
MembraneAddress: net.JoinHostPort("localhost", "50051"),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (t *golang) LaunchOptsForFunctionCollect(runCtx string) (LaunchOpts, error)
return LaunchOpts{
Image: t.DevImageName(),
TargetWD: path.Join("/go/src", module),
Cmd: strslice.StrSlice{"go", "run", "./" + t.handler},
Cmd: strslice.StrSlice{"go", "run", "./" + filepath.ToSlash(t.handler)},
Mounts: []mount.Mount{
{
Type: "bind",
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (t *javascript) LaunchOptsForFunctionCollect(runCtx string) (LaunchOpts, er
return LaunchOpts{
Image: t.DevImageName(),
Entrypoint: strslice.StrSlice{"ts-node"},
Cmd: strslice.StrSlice{"-T " + "/app/" + t.handler},
Cmd: strslice.StrSlice{"-T " + "/app/" + filepath.ToSlash(t.handler)},
TargetWD: "/app",
Mounts: []mount.Mount{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (t *typescript) LaunchOptsForFunctionCollect(runCtx string) (LaunchOpts, er
return LaunchOpts{
Image: t.DevImageName(),
Entrypoint: strslice.StrSlice{"ts-node"},
Cmd: strslice.StrSlice{"-T", "/app/" + t.handler},
Cmd: strslice.StrSlice{"-T", "/app/" + filepath.ToSlash(t.handler)},
TargetWD: "/app",
Mounts: []mount.Mount{
{
Expand Down
3 changes: 1 addition & 2 deletions pkg/stack/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package stack
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -126,7 +125,7 @@ func FromOptionsMinimal() (*Stack, error) {
if err != nil {
return nil, err
}
s := New(path.Base(absDir), sDir)
s := New(filepath.Base(absDir), sDir)

return s, nil
}
Expand Down

0 comments on commit 1fd5d71

Please sign in to comment.