hqjs / hq

Lightning fast, zero configuration, web application development server
https://hqjs.org
MIT License
126 stars 11 forks source link

Use the built-in fileURLToPath that works cross-platform #15

Closed liqi0816 closed 4 years ago

liqi0816 commented 4 years ago

Currently hq does not work properly on Windows because HQ_ROOT is not set correctly.

console.log(import.meta.url);
// file:///v:/hq/server.mjs
console.log(import.meta.url.slice('file://'.length));
// /v:/hq/server.mjs <== illegal for windows
console.log(path.dirname(url.fileURLToPath(import.meta.url)));
// v:\hq <== correct one

This pull request replaces .slice with the built-in url.fileURLToPath that ensures a cross-platform valid absolute path string.

hqjs commented 4 years ago

Great job @liqi0816! Thanks for the help. Did you check if everything else work as expected? Unfortunately I don't have windows to test it.

liqi0816 commented 4 years ago

Great job @liqi0816! Thanks for the help. Did you check if everything else work as expected? Unfortunately I don't have windows to test it.

I have tested an html/sass/typescript setting and it worked as expected. I guess(?) most other compilers will also work. Do we have a test case or a list of features that should be tested?

hqjs commented 4 years ago

Thanks, I guess it will work then. At the moment there are no proper tests I have about 20 projects that I'm trying before the release.

hqjs commented 4 years ago

published along with other improvements as @hqjs/hq@0.0.21