Made Makefile work with windows

This commit is contained in:
Pierre Finnimore 2024-06-20 19:29:20 +01:00
parent bb9f2ad740
commit e7e415c25e

View file

@ -4,6 +4,25 @@ ifneq (,$(wildcard ./.env))
export
endif
ifeq ($(OS),Windows_NT)
MAIN_PATH = /tmp/bin/main.exe
SYNC_ASSETS_COMMAND = go run github.com/makiuchi-d/arelo@v1.13.1 \
--target "./public" \
--pattern "**/*.js" \
--pattern "**/*.css" \
--delay "100ms" \
-- templ generate --notify-proxy
else
MAIN_PATH = tmp/bin/main
SYNC_ASSETS_COMMAND = go run github.com/cosmtrek/air@v1.51.0 \
--build.cmd "templ generate --notify-proxy" \
--build.bin "true" \
--build.delay "100" \
--build.exclude_dir "" \
--build.include_dir "public" \
--build.include_ext "js,css"
endif
# run templ generation in watch mode to detect all .templ files and
# re-create _templ.txt files on change, then send reload event to browser.
# Default url: http://localhost:7331
@ -13,7 +32,7 @@ templ:
# run air to detect any go file changes to re-build and re-run the server.
server:
@go run github.com/cosmtrek/air@v1.51.0 \
--build.cmd "go build --tags dev -o tmp/bin/main ./cmd/app/" --build.bin "tmp/bin/main" --build.delay "100" \
--build.cmd "go build --tags dev -o ${MAIN_PATH} ./cmd/app/" --build.bin "${MAIN_PATH}" --build.delay "100" \
--build.exclude_dir "node_modules" \
--build.include_ext "go" \
--build.stop_on_error "false" \
@ -29,13 +48,7 @@ watch-esbuild:
# watch for any js or css change in the assets/ folder, then reload the browser via templ proxy.
sync_assets:
go run github.com/cosmtrek/air@v1.51.0 \
--build.cmd "templ generate --notify-proxy" \
--build.bin "true" \
--build.delay "100" \
--build.exclude_dir "" \
--build.include_dir "public" \
--build.include_ext "js,css"
${SYNC_ASSETS_COMMAND}
# start the application in development
dev: