Skip to content

Commit 0ada49b

Browse files
authored
fix: fix windows compatible issue (#128)
1 parent 42b9db3 commit 0ada49b

File tree

5 files changed

+44
-15
lines changed

5 files changed

+44
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@ vite.config.ts.timestamp-*
147147
/rslint
148148
/bin/rslint
149149
npm/*/rslint
150+
npm/*/rslint.exe
150151

151152
.idea

cmd/rslint/main.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package main
22

33
import (
4-
"log"
54
"os"
6-
"os/signal"
7-
"syscall"
85
"time"
96
)
107

@@ -14,16 +11,6 @@ func main() {
1411

1512
const signalEnv = "RSLINT_STOP"
1613

17-
func waitForDebugSignal(pollInterval time.Duration) {
18-
if os.Getenv(signalEnv) == "" {
19-
return
20-
}
21-
log.Printf("waiting for debug SIGUSR2 signal, send signal to pid(%d) to continue", os.Getpid())
22-
sigCh := make(chan os.Signal, 1)
23-
signal.Notify(sigCh, syscall.SIGUSR2)
24-
sig := <-sigCh
25-
log.Println("SIGUSR2 signal:", sig)
26-
}
2714
func runMain() int {
2815
waitForDebugSignal(10000 * time.Millisecond)
2916
args := os.Args[1:]

cmd/rslint/signal_unix.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build !windows
2+
3+
package main
4+
5+
import (
6+
"log"
7+
"os"
8+
"os/signal"
9+
"syscall"
10+
"time"
11+
)
12+
13+
func waitForDebugSignal(pollInterval time.Duration) {
14+
if os.Getenv(signalEnv) == "" {
15+
return
16+
}
17+
log.Printf("waiting for debug SIGUSR2 signal, send signal to pid(%d) to continue", os.Getpid())
18+
sigCh := make(chan os.Signal, 1)
19+
signal.Notify(sigCh, syscall.SIGUSR2)
20+
sig := <-sigCh
21+
log.Println("SIGUSR2 signal:", sig)
22+
}

cmd/rslint/signal_windows.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//go:build windows
2+
3+
package main
4+
5+
import (
6+
"log"
7+
"os"
8+
"time"
9+
)
10+
11+
func waitForDebugSignal(pollInterval time.Duration) {
12+
if os.Getenv(signalEnv) == "" {
13+
return
14+
}
15+
log.Printf("Debug signal waiting is not supported on Windows. Continuing immediately.")
16+
// On Windows, we don't have SIGUSR2, so we just continue
17+
// In the future, we could implement Windows-specific debug mechanisms
18+
// like named pipes, events, or polling a file
19+
}

scripts/build-npm.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async function build_all() {
1414
{ os: 'darwin', arch: 'arm64', 'node-arch': 'arm64' },
1515
{ os: 'linux', arch: 'amd64', 'node-arch': 'x64' },
1616
{ os: 'linux', arch: 'arm64', 'node-arch': 'arm64' },
17-
// { os: 'windows', arch: 'amd64', 'node-arch': 'x64', 'node-os': 'win32' },
18-
// { os: 'windows', arch: 'arm64', 'node-arch': 'arm64', 'node-os': 'win32' },
17+
{ os: 'windows', arch: 'amd64', 'node-arch': 'x64', 'node-os': 'win32' },
18+
{ os: 'windows', arch: 'arm64', 'node-arch': 'arm64', 'node-os': 'win32' },
1919
];
2020
for (const platform of platforms) {
2121
await $`GOOS=${platform.os} GOARCH=${platform.arch} go build -o npm/${platform['node-os'] || platform.os}-${platform['node-arch']}/rslint ./cmd/rslint`;

0 commit comments

Comments
 (0)