-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temp directories aren't removed if CLI is killed #35
Comments
exists
fails when tmplr is run from a package bin script
ok I'd need to check these issues. the on the other issue, can you provide an example of |
These are the steps before the - read: pluginName
prompt: 'Enter the name of the plugin:'
default:
eval: '{{ filesystem.scopedir | Capital Case }}'
- read: outputDir
prompt: 'Enter the directory in which to create the plugin:'
default:
eval: '{{ pluginName | kebab-case }}'
- read: outputPath
eval: '../{{ outputDir }}' So if you enter a name like The package has been published and can be run as The code for the create tool is here: https://github.com/fwextensions/fwidgets/tree/main/packages/create-fwidgets |
ok so - if:
exists: '{{ outputPath }}/**/*' p.s. I think it would be nice to have |
Seems strange that |
exists
fails when tmplr is run from a package bin script
Good point. I'll look into the possibility of making |
so there was a discrepancy between the behaviour of however, generally temporary directories are NOT removed when the process is killed. to see this issue in action, check this sandbox. fixing this issue requires further work as the CLI needs to tap into |
Thanks for digging into it. Is there a better way of running tmplr from a node script? Can the node API be used directly? |
Kind of. It wouldn't solve this particular issue though, but I suspect it is a nice idea to make it easier to run some of |
I'm trying to create a package that you can use like
npm create foo
to scaffold a project directory using tmplr. To do this, there needs to be abin
key in thepackage.json
that gets run when thecreate
command is executed. I made a really simple node script for thebin.js
:I haven't published it yet, so testing locally via something like
npx ..\create-foo
. Getting the relative path from the current directory to where the.tmplr.yml
file seemed to be necessary, as I think it was creating the output within the temp directory and then removing it at the end, leaving nothing behind.Anyway, there's a prompt in the
tmplr
file and if I kill the command at that point, the local.use-***
temp directory is not cleaned up. If I run a "normal" recipe withnpx tmplr
, the directory is cleaned up even if I kill the process.Another thing that happens in this case is that the
exists
command doesn't seem to find a local directory. So if I run the script from/projects/test/
and there's a localfoo/
directory, theif: exists:
below doesn't match whenoutputPath
isfoo
, so the prompt isn't shown and the directory is removed:I belatedly realized I didn't actually need the
bin.js
file and could just put an npm command in thebin
field. But setting that tonpx tmplr use local:.
produces the same bugs as above.It's possible I'm not setting the paths or using the commands correctly here, but there may also be some bug when the
npx tmplr
command is run from some other package's npm script.The text was updated successfully, but these errors were encountered: