Request for `using (TempDirectory(x))` syntax
See original GitHub issueInstead of this:
.Does(() =>
{
var stagingDir = Directory("path");
CreateDirectory(stagingDir);
try
{
CleanDirectory(stagingDir);
CopyFiles("glob", stagingDir);
// Run some non-globbable tool on stagingDir
}
finally
{
DeleteDirectory(stagingDir, true);
}
// stagingDir is gone
}
I would like to be able to do this:
.Does(() =>
{
var stagingDir = Directory("path");
using (TempDirectory(stagingDir))
{
CopyFiles("glob", stagingDir);
// Run some non-globbable tool on stagingDir
}
// stagingDir is gone
}
Willing to PR if you like this idea.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
bash - How to create a temporary directory?
Use mktemp -d . It creates a temporary directory with a random name and makes sure that file doesn't already exist. You need...
Read more >Providing option to override temp location would be a great ...
When I try to recreate a tempdir using check=TRUE , a new tempdir is created, but callr still points back to the old...
Read more >Process of Creating Directory and Temp ...
This article explains you how to create primary directory and temporary directory in node.js step by step process. Find a detailed analysis ...
Read more >Transient data storage for different users - how to? - shiny
Basically the user uploads some data, it will be interactively converted by the user and in the end a lot of plots and...
Read more >Working and unit testing with temporary files in Java
In this article, I examine the use of temporary files in Java. ... two major versions—JUnit 4.x and 5.x—I provide code for both...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jnm2 The problem with something like
using(WorkingDirectory(x))
is that it would manipulate global state. This would make it problematic to do things like task parallelisation. So I think that we wait with a PR until we have way of solving this.@patriksvensson Oh good! I didn’t know parallelization was a goal, but I’m glad it is. I wonder if using
AsyncLocal
for the implementation would be all that’s needed?