Closed fwextensions closed 9 months ago
Has it been tested on Windows?
Not specifically, the APIs should generally behave in a cross-platform manner, though there is always possibility of some little mistake 😅 Can you try the following recipe?
steps:
- read: pluginName
prompt: What is the name of your plugin?
default: Bloop Blorp
- read: derp
from file: derp.txt
- write: '{{ derp }}'
to: derp.txt
Thanks, that does work. Isn't that what update
should be doing?
Here's the copy
command that also doesn't work:
- copy: package-template.json
to: out.json
The template file has several tokens like "name": "{{ tmplr.pluginName | kebab-case }}"
. The out.json
file doesn't get generated at all when run in the Windows terminal, but it does when run in WSL. I noticed that tokens in the file that don't have the tmplr.
prefix actually don't get replaced . I thought that prefix was optional, but maybe need to read the docs more.
Thanks, that does work. Isn't that what update should be doing?
Yes, but they also support handling multiple files using glob patterns, which (I just learned) don't work smoothly in windows due to different path schema (\
is a separator in windows while an escaping character in minimatch which I was using for matching glob patterns).
I've now updated the fs lib to normalise paths and always use forward slash regardless of the platform, and the core lib to assume a POSIX format for file paths. I've also updated CI for these libraries (and the main repo) to run tests on windows as well, and have added an e2e test specifically reflecting this case.
@fwextensions Updating to tmplr@0.3.0
should fix this issue, please check and close this issue if it does.
I thought that prefix was optional, but maybe need to read the docs more.
Or perhaps I need to update the docs for further clarity 😅
Excellent, that worked! Thanks for the quick fix!
Funny seeing my ridiculous temp filenames enshrined in a test.
they also support handling multiple files using glob patterns, which (I just learned) don't work smoothly in windows due to different path schema
Yeah, that accident of history has caused a lot of heartache.
Re: needing the tmplr.
prefix, here's the part that tripped me up:
For using variables in expressions, you don't need the tmplr. prefix.
Maybe emphasizing that that only applies within the YAML file, and not within other files that are processed.
@fwextensions thanks for the tip, I tried to further clarify that section.
I really want to use this utility, but it doesn't seem to work reliably on Windows. I've got a super simple test
.tmplr.yml
file that looks like this:derp.txt
:When I run
npx tmplr preview
in the Windows terminal, it prompts for thepluginName
var and correctly writes it out toffs.txt
in the preview folder. Butderp.txt
doesn't get updated at all. I also had acopy
command that I was trying that similarly had no effect.If I run the same command inside a WSL shell, the
derp.txt
file is updated as expected. So this seems like a Windows vs. Linux issue. Has it been tested on Windows?