Skip to content

Commit 4426eb2

Browse files
authored
Merge pull request #121 from nitrictech/fix/nodemon-restart-windows
fix: nodemon poll required for hot reload windows
2 parents 389d679 + 8e3a278 commit 4426eb2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

pkg/runtime/javascript.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io"
2222
"path/filepath"
23+
osruntime "runtime"
2324
"strings"
2425

2526
"github.com/docker/docker/api/types/mount"
@@ -110,6 +111,15 @@ func (t *javascript) LaunchOptsForFunctionCollect(runCtx string) (LaunchOpts, er
110111
}
111112

112113
func (t *javascript) LaunchOptsForFunction(runCtx string) (LaunchOpts, error) {
114+
var cmd []string
115+
116+
if osruntime.GOOS == "windows" {
117+
// https://github.com/remy/nodemon#application-isnt-restarting
118+
cmd = strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "-L", "--exec", "node " + "/app/" + filepath.ToSlash(t.handler)}
119+
} else {
120+
cmd = strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "--exec", "node " + "/app/" + filepath.ToSlash(t.handler)}
121+
}
122+
113123
return LaunchOpts{
114124
Mounts: []mount.Mount{
115125
{
@@ -120,6 +130,6 @@ func (t *javascript) LaunchOptsForFunction(runCtx string) (LaunchOpts, error) {
120130
},
121131
TargetWD: "/app",
122132
Entrypoint: strslice.StrSlice{"nodemon"},
123-
Cmd: strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "--exec", "node " + "/app/" + filepath.ToSlash(t.handler)},
133+
Cmd: cmd,
124134
}, nil
125135
}

pkg/runtime/typescript.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io"
2222
"path/filepath"
23+
osruntime "runtime"
2324
"strings"
2425

2526
"github.com/docker/docker/api/types/mount"
@@ -113,6 +114,15 @@ func (t *typescript) LaunchOptsForFunctionCollect(runCtx string) (LaunchOpts, er
113114
}
114115

115116
func (t *typescript) LaunchOptsForFunction(runCtx string) (LaunchOpts, error) {
117+
var cmd []string
118+
119+
if osruntime.GOOS == "windows" {
120+
// https://github.com/remy/nodemon#application-isnt-restarting
121+
cmd = strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "-L", "--exec", "ts-node -T " + "/app/" + filepath.ToSlash(t.handler)}
122+
} else {
123+
cmd = strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "--exec", "ts-node -T " + "/app/" + filepath.ToSlash(t.handler)}
124+
}
125+
116126
return LaunchOpts{
117127
TargetWD: "/app",
118128
Mounts: []mount.Mount{
@@ -123,6 +133,6 @@ func (t *typescript) LaunchOptsForFunction(runCtx string) (LaunchOpts, error) {
123133
},
124134
},
125135
Entrypoint: strslice.StrSlice{"nodemon"},
126-
Cmd: strslice.StrSlice{"--watch", "/app/**", "--ext", "ts,js,json", "--exec", "ts-node -T " + "/app/" + filepath.ToSlash(t.handler)},
136+
Cmd: cmd,
127137
}, nil
128138
}

0 commit comments

Comments
 (0)