Skip to content

Commit 7d4f186

Browse files
committed
v0.1.0
1 parent 6d0a5c6 commit 7d4f186

File tree

5 files changed

+74
-6
lines changed

5 files changed

+74
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
/.env
12
/nwatch
3+
/releases

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Variables
2+
VERSION ?= 0.1.0
3+
4+
# .env
5+
ifneq (,$(wildcard ./.env))
6+
include .env
7+
export
8+
endif
9+
10+
## Print this message and exit
11+
.PHONY: help
12+
help:
13+
@cat $(MAKEFILE_LIST) | awk ' \
14+
/^([0-9a-z-]+):.*$$/ { \
15+
if (description[0] != "") { \
16+
printf("\x1b[36mmake %s\x1b[0m\n", substr($$1, 0, length($$1)-1)); \
17+
for (i in description) { \
18+
printf("| %s\n", description[i]); \
19+
} \
20+
printf("\n"); \
21+
split("", description); \
22+
descriptionIndex = 0; \
23+
} \
24+
} \
25+
/^##/ { \
26+
description[descriptionIndex++] = substr($$0, 4); \
27+
} \
28+
'
29+
30+
## Build development version
31+
.PHONY: dev
32+
dev:
33+
go build
34+
35+
## Build production version
36+
.PHONY: prod
37+
prod:
38+
CGO_ENABLED=0 go build -ldflags='-s -w -X main.version=$(VERSION)'
39+
40+
## Install to ${GOPATH}/bin
41+
.PHONY: install
42+
install:
43+
CGO_ENABLED=0 go install -ldflags='-s -w -X main.version=$(VERSION)'
44+
45+
## Build and create a release
46+
.PHONY: release
47+
release:
48+
if git rev-parse v$(VERSION) >/dev/null 2>&1; then echo "ERROR: Tag 'v$(VERSION)' already exists"; exit 1; fi
49+
rm -rf ./releases/v$(VERSION)
50+
mkdir -p ./releases/v$(VERSION)
51+
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-amd64 -ldflags='-s -w -X main.version=$(VERSION)'
52+
GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-386 -ldflags='-s -w -X main.version=$(VERSION)'
53+
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-arm64 -ldflags='-s -w -X main.version=$(VERSION)'
54+
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-arm -ldflags='-s -w -X main.version=$(VERSION)'
55+
GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-ppc64le -ldflags='-s -w -X main.version=$(VERSION)'
56+
GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-linux-s390x -ldflags='-s -w -X main.version=$(VERSION)'
57+
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-darwin-amd64 -ldflags='-s -w -X main.version=$(VERSION)'
58+
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-darwin-arm64 -ldflags='-s -w -X main.version=$(VERSION)'
59+
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ./releases/v$(VERSION)/nwatch-v$(VERSION)-windows-amd64.exe -ldflags='-s -w -X main.version=$(VERSION)'
60+
gh release create v0.1.0 --title='' --notes='' ./releases/v0.1.0/nwatch-*

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ A simple watch/build/run daemon.
44

55
Originally made to watch and rebuild Go projects.
66

7-
87
## Installation
98

9+
Download a prebuilt binary from the [releases](https://github.com/tzvetkoff-go/nwatch/releases) page or build it yourself:
10+
1011
``` bash
11-
go install github.com/tzvetkoff-go/nwatch
12+
git clone https://github.com/tzvetkoff-go/nwatch.git
13+
cd nwatch
14+
make install
1215
```
1316

1417
## Common usage
@@ -24,8 +27,7 @@ go install github.com/tzvetkoff-go/nwatch
2427
| `-i IGN` | `--ignore=IGN` | File patterns to ignore | `-i '*-go-tmp-umask'` |
2528
| `-b BLD` | `--build=BLD` | Build command to execute | `-b 'go build'` |
2629
| `-s SRV` | `--server=SRV` | Server command to run after successful build | `-s './webserver start'` |
27-
| `-w ERR` | `--error-server=ERR` | Web server address in case of an error | `-w 0.0.0.0:1337` |
28-
30+
| `-w ERR` | `--error-server=ERR` | Web server address in case of an error | `-w 0.0.0.0:1337` |
2931

3032
## Pattern matching
3133

nwatch.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
"github.com/tzvetkoff-go/nwatch/pkg/watcher"
2222
)
2323

24+
// version ...
25+
var version = "(dev)"
26+
2427
// usage ...
2528
func usage(f io.Writer, name string) {
2629
fmt.Fprintln(f, "Usage:")
@@ -207,7 +210,7 @@ func main() {
207210

208211
// Version
209212
if *pVersion {
210-
fmt.Println("0.1.0")
213+
fmt.Println(version)
211214
os.Exit(0)
212215
}
213216

pkg/watcher/watcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package watcher
33
import (
44
"os"
55
"path/filepath"
6+
"strings"
67
"time"
78

89
"github.com/fsnotify/fsnotify"
@@ -47,7 +48,7 @@ func (w *Watcher) Add(dir string) {
4748

4849
if info.IsDir() {
4950
for _, exclude := range w.Excludes {
50-
if path == exclude {
51+
if path == exclude || strings.HasPrefix(path, exclude+"/") {
5152
return nil
5253
}
5354
}

0 commit comments

Comments
 (0)