schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs, SSR and SSG.
https://jasprpad.schultek.de
MIT License
1.07k stars 65 forks source link

fix: _findRootProjectDir enters infinite loop on Windows #130

Closed fuzzybinary closed 9 months ago

fuzzybinary commented 10 months ago

Description

When running jaspr through dart .\lib\main.dart or through a built Jaspr executable (made with jaspr build), the _findRootProjectDir (in lib/src/server/server_handler.dart) can enter an infinite loop.

This is because (for reasons) Platform.script.path returns the the path with a leading slash. E.g.:

/C:/Users/Jeff%20Ward/Projects/newton_jaspr/lib/main.dart

This causes 3 issues that combine to create an infinite loop.

If looks like the proper fix is to use Platform.script.toFilePath()

Steps To Reproduce

1) Create a jaspr project on windows 2) Run dart lib/main.dart

-or-

1) Create a jaspr project on windows 2) run jaspr build 3) Rename build/jaspr/app to build/jaspr/app.exe 4) Run app.exe

Doctor Output

[✓] Jaspr CLI (Version 0.9.2) • Dart Version 3.1.3 (stable) (Tue Sep 26 14:25:13 2023 +0000) on "windows_x64" at C:\Users\Jeff Ward\Projects\flutter\bin\cache\dart-sdk\bin\dart.exe • Running on windows "Windows 10 Home Single Language" 10.0 (Build 19045) - Locale en-US • Analytics: Enabled

[✓] Current Project • Dependencies on core packages: • jaspr: ^0.9.2 • jaspr_builder: ^0.9.2 (dev) • jaspr_router: ^0.3.0 • Uses server-side rendering: true • Uses experimental compilers: false • Uses flutter embedding: false

Expected Behavior

You can run a Jaspr server on windows.