skymethod / denoflare

Develop, test, and deploy Cloudflare Workers with Deno.
https://denoflare.dev
MIT License
655 stars 32 forks source link

importText under windows breaks when using a subdirectory #40

Closed FaeyUmbrea closed 1 year ago

FaeyUmbrea commented 1 year ago

How to reproduce:

1) Have a file in a directory other than the script file. (i.e. src/files) 2) Reference the file using importText 3) Run "push" under Windows

Expected Result: From testing this in WSL, it should just automagically work.

Actual Result: Under Windows, probably due to the whole \ instead of / thing. You get a broken import ("filefile.txt" does not exist). It works perfectly fine if the script and file are in the same subfolder though.

johnspurlock-skymethod commented 1 year ago

Thanks for reporting this. I don't have a windows setup at the moment, would you mind submitting a PR?

Here is where those local file urls are fetched in this case of plain text: https://github.com/skymethod/denoflare/blob/67ebc621fc6ca1da3b92f73f03ac5d734c4f9f7d/common/import_text.ts#L19

Was hoping using those path functions from the standard lib would handle these os-specific separators.

FaeyUmbrea commented 1 year ago

Here we go: #42 The fix is after all, pretty easy. Since unix does not allow \ in paths, simply replacing all \ with / in any path will fix it. Please note: Local mode deployment works, the issue is only present on upload because cloudflare can't handle import '.\path\file.txt' rather than import './path/file.txt'

johnspurlock-skymethod commented 1 year ago

Fixed by PR