elm-script icon indicating copy to clipboard operation
elm-script copied to clipboard

~/path/to/file.txt doesn't work

Open MartinSStewart opened this issue 5 years ago • 1 comments

I tried to read from a file and found that file paths in this form ~/path/to/file.txt don't work. If I change it to /Users/MyAccount/path/to/file.txt then it does work however.

MartinSStewart avatar Jun 04 '20 16:06 MartinSStewart

Ah interesting, seems that the logic in the internal Path.isAbsolute function should be improved. The quick fix would be to recognize paths starting in either / or ~ as absolute paths on POSIX platforms, but there are probably other cases too (e.g. paths that include an environment variable, like $HOME/path/to/file.txt).

Could be that the better solution is to restructure the code to avoid any actual logic like this in Elm and just delegate it to the Deno side - e.g. encode the working directory and given path separately, and then use path.resolve or similar on the Deno side and let Deno figure out whether the given path is absolute or relative.

ianmackenzie avatar Jun 04 '20 16:06 ianmackenzie