-
Notifications
You must be signed in to change notification settings - Fork 95
When using the template option tmp does not join paths with opts.dir or tmpDir if no path is given in the template #143
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
Comments
On second thought, we should elaborate on the template thing a bit. E.g. sprintf like functionality allowing for datetime/random chars. As it stands now, template is actually the same as a combination of the following options: dir, prefix, postfix and a random count, where count is limited to 6. Perhaps we should also introduce a length option that allows the user to control the amount of random chars appended to the prefix during normal non template operation instead of the fixed/default 12 random chars as it is now the case. And when using template, one should have the option to
where and so on. What do you think of this instead of merely limiting template to a prefix/random/postfix? |
I am not sure I like this change. First of all this is a breaking change, second this will also break the behavior of the Although the idea of having a more generic templating sounds nice at the first thought but it would lead too far and I am not sure that it would be widely used. If somebody needs something like that then they could define their own and then pass the generated path as the But I am open for further discussion about it. |
@raszi Okay, I can see that backwards compatibility is an issue here. How about then checking whether template resembles a relative or absolute path? If not, we would append opts.dir || tmpDir instead? As for the extensions to the template: sure, this can easily be accomplished by an external templating system. How about then allowing the user to pass in a callable as a template? Which, upon invocation, would return the rendered string? We could be passing the random char generator as input to that callable as well as opts.dir || tmpDir, e.g.
This way we remain backwards compatible and provide for future extension. |
I have adjusted the description and summary. |
@raszi The mkstemps like 'template system' is not compatible with the Windows platform and is very failure prone for users, especially when using hard coded paths. See https://ci.appveyor.com/project/raszi/node-tmp/build/1.0.132/job/6cln6y1vlxxql69q For now, I will readjust the failing test cases to use tmp.tmpdir instead and use path.join to make these test cases work. See #141 |
See also #156 |
prepend opts.dir || tmpDir to template if no path is given
Operating System
NodeJS Version
Tmp Version
All since the time the template option was introduced up to 0.31
Expected Behavior
When passing in the template option, tmp should join paths with either the dir option or the default tmpDir if the template does not already contain a path.
Experienced Behavior
Temporary files and directories will be created in the CWD. In addition, both absolute and relative paths passed as part of the template will not be rejected.
See also
#141
The text was updated successfully, but these errors were encountered: