Skip to content

Commit 8c7db4a

Browse files
committed
🤖 refactor: use conditional RUNNER variable for Windows compatibility
- Add RUNNER variable that uses npx on Windows, bun x elsewhere - Windows: bun x doesn't correctly pass arguments, so use npm run/npx - Non-Windows: Continue using bun x for better performance - Update all commands to use $(RUNNER) instead of hardcoded bun x or npx - Add comments explaining why Windows needs different approach This ensures consistent build behavior across all platforms while working around Windows-specific limitations with bun's argument passing.
1 parent 2acdfbf commit 8c7db4a

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

Makefile

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
# exist in Chocolatey's make environment or on GitHub Actions windows-latest.
2929
ifeq ($(OS),Windows_NT)
3030
SHELL := bash
31+
# Windows: Use npm/npx because bun x doesn't correctly pass arguments on Windows
32+
RUNNER := npx
3133
else
3234
SHELL := /bin/bash
35+
# Non-Windows: Use bun x for better performance
36+
RUNNER := bun x
3337
endif
3438
.SHELLFLAGS := -eu -o pipefail -c
3539

@@ -102,8 +106,9 @@ help: ## Show this help message
102106
## Development
103107
dev: node_modules/.installed build-main clean-cache ## Start development server (Vite + nodemon watcher for Windows compatibility)
104108
@echo "Starting dev mode (2 watchers: nodemon for main process, vite for renderer)..."
105-
@NODE_OPTIONS="--max-old-space-size=4096" npx concurrently -k --raw \
106-
"npx nodemon --exec node scripts/build-main-watch.js" \
109+
@# On Windows, use npm run because bun x doesn't correctly pass arguments
110+
@NODE_OPTIONS="--max-old-space-size=4096" $(RUNNER) concurrently -k --raw \
111+
"$(RUNNER) nodemon --exec node scripts/build-main-watch.js" \
107112
"vite"
108113

109114
clean-cache: ## Clean Vite cache (helps with EMFILE errors on Windows)
@@ -116,15 +121,16 @@ dev-server: node_modules/.installed build-main ## Start server mode with hot rel
116121
@echo " Frontend (with HMR): http://$(or $(VITE_HOST),localhost):$(or $(VITE_PORT),5173)"
117122
@echo ""
118123
@echo "For remote access: make dev-server VITE_HOST=0.0.0.0 BACKEND_HOST=0.0.0.0"
119-
@npx concurrently -k \
120-
"npx nodemon --exec node scripts/build-main-watch.js" \
121-
"bun x nodemon --watch dist/main.js --watch dist/main-server.js --delay 500ms --exec \"node dist/main.js server --host $(or $(BACKEND_HOST),localhost) --port $(or $(BACKEND_PORT),3000)\"" \
124+
@# On Windows, use npm run because bun x doesn't correctly pass arguments
125+
@$(RUNNER) concurrently -k \
126+
"$(RUNNER) nodemon --exec node scripts/build-main-watch.js" \
127+
"$(RUNNER) nodemon --watch dist/main.js --watch dist/main-server.js --delay 500ms --exec \"node dist/main.js server --host $(or $(BACKEND_HOST),localhost) --port $(or $(BACKEND_PORT),3000)\"" \
122128
"$(SHELL) -lc \"CMUX_VITE_HOST=$(or $(VITE_HOST),127.0.0.1) CMUX_VITE_PORT=$(or $(VITE_PORT),5173) VITE_BACKEND_URL=http://$(or $(BACKEND_HOST),localhost):$(or $(BACKEND_PORT),3000) vite\""
123129

124130

125131

126132
start: node_modules/.installed build-main build-preload build-static ## Build and start Electron app
127-
@bun x electron --remote-debugging-port=9222 .
133+
@$(RUNNER) electron --remote-debugging-port=9222 .
128134

129135
## Build targets (can run in parallel)
130136
build: node_modules/.installed src/version.ts build-renderer build-main build-preload build-icons build-static ## Build all targets
@@ -134,7 +140,7 @@ build-main: node_modules/.installed dist/main.js ## Build main process
134140
dist/main.js: src/version.ts tsconfig.main.json tsconfig.json $(TS_SOURCES)
135141
@echo "Building main process..."
136142
@NODE_ENV=production $(TSGO) -p tsconfig.main.json
137-
@NODE_ENV=production bun x tsc-alias -p tsconfig.main.json
143+
@NODE_ENV=production $(RUNNER) tsc-alias -p tsconfig.main.json
138144

139145
build-preload: node_modules/.installed dist/preload.js ## Build preload script
140146

@@ -149,7 +155,7 @@ dist/preload.js: src/preload.ts $(TS_SOURCES)
149155

150156
build-renderer: node_modules/.installed src/version.ts ## Build renderer process
151157
@echo "Building renderer..."
152-
@bun x vite build
158+
@$(RUNNER) vite build
153159

154160
build-static: ## Copy static assets to dist
155161
@echo "Copying static assets..."
@@ -201,15 +207,15 @@ lint-fix: node_modules/.installed ## Run linter with --fix
201207
@./scripts/lint.sh --fix
202208

203209
typecheck: node_modules/.installed src/version.ts ## Run TypeScript type checking (uses tsgo for 10x speedup)
204-
@npx concurrently -g \
210+
@$(RUNNER) concurrently -g \
205211
"$(TSGO) --noEmit" \
206212
"$(TSGO) --noEmit -p tsconfig.main.json"
207213

208214
check-deadcode: node_modules/.installed ## Check for potential dead code (manual only, not in static-check)
209215
@echo "Checking for potential dead code with ts-prune..."
210216
@echo "(Note: Some unused exports are legitimate - types, public APIs, entry points, etc.)"
211217
@echo ""
212-
@bun x ts-prune -i '(test|spec|mock|bench|debug|storybook)' \
218+
@$(RUNNER) ts-prune -i '(test|spec|mock|bench|debug|storybook)' \
213219
| grep -v "used in module" \
214220
| grep -v "src/App.tsx.*default" \
215221
| grep -v "src/types/" \
@@ -219,7 +225,7 @@ check-deadcode: node_modules/.installed ## Check for potential dead code (manual
219225
## Testing
220226
test-integration: node_modules/.installed build-main ## Run all tests (unit + integration)
221227
@bun test src
222-
@TEST_INTEGRATION=1 bun x jest tests
228+
@TEST_INTEGRATION=1 $(RUNNER) jest tests
223229

224230
test-unit: node_modules/.installed build-main ## Run unit tests
225231
@bun test src
@@ -234,52 +240,52 @@ test-coverage: ## Run tests with coverage
234240

235241
test-e2e: ## Run end-to-end tests
236242
@$(MAKE) build
237-
@CMUX_E2E_LOAD_DIST=1 CMUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 bun x playwright test --project=electron $(PLAYWRIGHT_ARGS)
243+
@CMUX_E2E_LOAD_DIST=1 CMUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 $(RUNNER) playwright test --project=electron $(PLAYWRIGHT_ARGS)
238244

239245
## Distribution
240246
dist: build ## Build distributable packages
241-
@bun x electron-builder --publish never
247+
@$(RUNNER) electron-builder --publish never
242248

243249
# Parallel macOS builds - notarization happens concurrently
244250
dist-mac: build ## Build macOS distributables (x64 + arm64)
245251
@if [ -n "$$CSC_LINK" ]; then \
246252
echo "🔐 Code signing enabled - building sequentially to avoid keychain conflicts..."; \
247-
bun x electron-builder --mac --x64 --publish never && \
248-
bun x electron-builder --mac --arm64 --publish never; \
253+
$(RUNNER) electron-builder --mac --x64 --publish never && \
254+
$(RUNNER) electron-builder --mac --arm64 --publish never; \
249255
else \
250256
echo "Building macOS architectures in parallel..."; \
251-
bun x electron-builder --mac --x64 --publish never & pid1=$$! ; \
252-
bun x electron-builder --mac --arm64 --publish never & pid2=$$! ; \
257+
$(RUNNER) electron-builder --mac --x64 --publish never & pid1=$$! ; \
258+
$(RUNNER) electron-builder --mac --arm64 --publish never & pid2=$$! ; \
253259
wait $$pid1 && wait $$pid2; \
254260
fi
255261
@echo "✅ Both architectures built successfully"
256262

257263
dist-mac-release: build ## Build and publish macOS distributables (x64 + arm64)
258264
@if [ -n "$$CSC_LINK" ]; then \
259265
echo "🔐 Code signing enabled - building sequentially to avoid keychain conflicts..."; \
260-
bun x electron-builder --mac --x64 --publish always && \
261-
bun x electron-builder --mac --arm64 --publish always; \
266+
$(RUNNER) electron-builder --mac --x64 --publish always && \
267+
$(RUNNER) electron-builder --mac --arm64 --publish always; \
262268
else \
263269
echo "Building and publishing macOS architectures in parallel..."; \
264-
bun x electron-builder --mac --x64 --publish always & pid1=$$! ; \
265-
bun x electron-builder --mac --arm64 --publish always & pid2=$$! ; \
270+
$(RUNNER) electron-builder --mac --x64 --publish always & pid1=$$! ; \
271+
$(RUNNER) electron-builder --mac --arm64 --publish always & pid2=$$! ; \
266272
wait $$pid1 && wait $$pid2; \
267273
fi
268274
@echo "✅ Both architectures built and published successfully"
269275

270276
dist-mac-x64: build ## Build macOS x64 distributable only
271277
@echo "Building macOS x64..."
272-
@bun x electron-builder --mac --x64 --publish never
278+
@$(RUNNER) electron-builder --mac --x64 --publish never
273279

274280
dist-mac-arm64: build ## Build macOS arm64 distributable only
275281
@echo "Building macOS arm64..."
276-
@bun x electron-builder --mac --arm64 --publish never
282+
@$(RUNNER) electron-builder --mac --arm64 --publish never
277283

278284
dist-win: build ## Build Windows distributable
279-
@bun x electron-builder --win --publish never
285+
@$(RUNNER) electron-builder --win --publish never
280286

281287
dist-linux: build ## Build Linux distributable
282-
@bun x electron-builder --linux --publish never
288+
@$(RUNNER) electron-builder --linux --publish never
283289

284290
## Documentation
285291
docs: ## Serve documentation locally
@@ -294,19 +300,19 @@ docs-watch: ## Watch and rebuild documentation
294300
## Storybook
295301
storybook: node_modules/.installed ## Start Storybook development server
296302
$(check_node_version)
297-
@bun x storybook dev -p 6006 $(STORYBOOK_OPEN_FLAG)
303+
@$(RUNNER) storybook dev -p 6006 $(STORYBOOK_OPEN_FLAG)
298304

299305
storybook-build: node_modules/.installed src/version.ts ## Build static Storybook
300306
$(check_node_version)
301-
@bun x storybook build
307+
@$(RUNNER) storybook build
302308

303309
test-storybook: node_modules/.installed ## Run Storybook interaction tests (requires Storybook to be running or built)
304310
$(check_node_version)
305-
@bun x test-storybook
311+
@$(RUNNER) test-storybook
306312

307313
chromatic: node_modules/.installed ## Run Chromatic for visual regression testing
308314
$(check_node_version)
309-
@bun x chromatic --exit-zero-on-changes
315+
@$(RUNNER) chromatic --exit-zero-on-changes
310316

311317
## Benchmarks
312318
benchmark-terminal: ## Run Terminal-Bench with the cmux agent (use TB_DATASET/TB_SAMPLE_SIZE/TB_TIMEOUT/TB_ARGS to customize)

0 commit comments

Comments
 (0)