Skip to content

Commit 9d72626

Browse files
committed
fix #250: introduce tmpdir option for overriding the system tmp dir
1 parent 16acc7a commit 9d72626

File tree

8 files changed

+143
-47
lines changed

8 files changed

+143
-47
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# CHANGELOG
22

3+
## tmp v0.2.1
4+
5+
- [#250](https://github.com/raszi/node-tmp/issues/250)
6+
7+
***FEATURE***
8+
9+
New option `tmpdir` that allows users to override the system's tmpdir.
10+
11+
```
12+
tmp.dirSync({tmpdir: '/mnt/tmp'});
13+
```
14+
15+
***BUG FIX***
16+
17+
Changes to options will no longer leak out.
18+
319
## tmp v0.2.0
420

521
- drop support for node version < v8.17.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ All options are optional :)
350350
absolute paths are fine as long as they point to a location under the system's default temporary directory.
351351
Any directories along the so specified path must exist, otherwise a ENOENT error will be thrown upon access,
352352
as tmp will not check the availability of the path, nor will it establish the requested path for you.
353+
* `tmpdir`: allows you to override the system's root tmp directory
353354
* `tries`: how many times should the function try to get a unique filename before giving up, default `3`
354355
* `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`
355356
* In order to clean up, you will have to call the provided `cleanupCallback` function manually.

docs/global.html

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h5>Parameters:</h5>
251251

252252
<dt class="tag-source">Source:</dt>
253253
<dd class="tag-source"><ul class="dummy"><li>
254-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line191">line 191</a>
254+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line192">line 192</a>
255255
</li></ul></dd>
256256

257257

@@ -388,7 +388,7 @@ <h5>Parameters:</h5>
388388

389389
<dt class="tag-source">Source:</dt>
390390
<dd class="tag-source"><ul class="dummy"><li>
391-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line219">line 219</a>
391+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line220">line 220</a>
392392
</li></ul></dd>
393393

394394

@@ -628,7 +628,7 @@ <h5>Parameters:</h5>
628628

629629
<dt class="tag-source">Source:</dt>
630630
<dd class="tag-source"><ul class="dummy"><li>
631-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line126">line 126</a>
631+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line127">line 127</a>
632632
</li></ul></dd>
633633

634634

@@ -765,7 +765,7 @@ <h5>Parameters:</h5>
765765

766766
<dt class="tag-source">Source:</dt>
767767
<dd class="tag-source"><ul class="dummy"><li>
768-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line164">line 164</a>
768+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line165">line 165</a>
769769
</li></ul></dd>
770770

771771

@@ -908,7 +908,7 @@ <h4 class="name" id="setGracefulCleanup"><span class="type-signature"></span>set
908908

909909
<dt class="tag-source">Source:</dt>
910910
<dd class="tag-source"><ul class="dummy"><li>
911-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line630">line 630</a>
911+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line655">line 655</a>
912912
</li></ul></dd>
913913

914914

@@ -1434,7 +1434,7 @@ <h5>Parameters:</h5>
14341434

14351435
<dt class="tag-source">Source:</dt>
14361436
<dd class="tag-source"><ul class="dummy"><li>
1437-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line713">line 713</a>
1437+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line739">line 739</a>
14381438
</li></ul></dd>
14391439

14401440

@@ -1522,7 +1522,7 @@ <h4 class="name" id="cleanupCallbackSync"><span class="type-signature"></span>cl
15221522

15231523
<dt class="tag-source">Source:</dt>
15241524
<dd class="tag-source"><ul class="dummy"><li>
1525-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line720">line 720</a>
1525+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line746">line 746</a>
15261526
</li></ul></dd>
15271527

15281528

@@ -1729,7 +1729,7 @@ <h5>Parameters:</h5>
17291729

17301730
<dt class="tag-source">Source:</dt>
17311731
<dd class="tag-source"><ul class="dummy"><li>
1732-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line699">line 699</a>
1732+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line725">line 725</a>
17331733
</li></ul></dd>
17341734

17351735

@@ -1936,7 +1936,7 @@ <h5>Parameters:</h5>
19361936

19371937
<dt class="tag-source">Source:</dt>
19381938
<dd class="tag-source"><ul class="dummy"><li>
1939-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line706">line 706</a>
1939+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line732">line 732</a>
19401940
</li></ul></dd>
19411941

19421942

@@ -2093,7 +2093,7 @@ <h5 class="subsection-title">Properties:</h5>
20932093

20942094
<dt class="tag-source">Source:</dt>
20952095
<dd class="tag-source"><ul class="dummy"><li>
2096-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line671">line 671</a>
2096+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line697">line 697</a>
20972097
</li></ul></dd>
20982098

20992099

@@ -2317,7 +2317,7 @@ <h5>Parameters:</h5>
23172317

23182318
<dt class="tag-source">Source:</dt>
23192319
<dd class="tag-source"><ul class="dummy"><li>
2320-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line683">line 683</a>
2320+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line709">line 709</a>
23212321
</li></ul></dd>
23222322

23232323

@@ -2555,7 +2555,7 @@ <h5>Parameters:</h5>
25552555

25562556
<dt class="tag-source">Source:</dt>
25572557
<dd class="tag-source"><ul class="dummy"><li>
2558-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line691">line 691</a>
2558+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line717">line 717</a>
25592559
</li></ul></dd>
25602560

25612561

@@ -2735,7 +2735,7 @@ <h5 class="subsection-title">Properties:</h5>
27352735

27362736
<dt class="tag-source">Source:</dt>
27372737
<dd class="tag-source"><ul class="dummy"><li>
2738-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line664">line 664</a>
2738+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line690">line 690</a>
27392739
</li></ul></dd>
27402740

27412741

@@ -2978,7 +2978,7 @@ <h5 class="subsection-title">Properties:</h5>
29782978

29792979

29802980

2981-
<td class="description last">tmp directory relative to the system tmp directory to use</td>
2981+
<td class="description last">tmp directory relative to the root tmp directory in use</td>
29822982
</tr>
29832983

29842984

@@ -3045,6 +3045,37 @@ <h5 class="subsection-title">Properties:</h5>
30453045

30463046

30473047

3048+
<tr>
3049+
3050+
<td class="name"><code>tmpdir</code></td>
3051+
3052+
3053+
<td class="type">
3054+
3055+
3056+
<span class="param-type">string</span>
3057+
3058+
3059+
3060+
</td>
3061+
3062+
3063+
<td class="attributes">
3064+
3065+
3066+
3067+
&lt;nullable><br>
3068+
3069+
</td>
3070+
3071+
3072+
3073+
3074+
<td class="description last">the root tmp directory which overrides the os tmpdir</td>
3075+
</tr>
3076+
3077+
3078+
30483079
<tr>
30493080

30503081
<td class="name"><code>unsafeCleanup</code></td>
@@ -3172,7 +3203,7 @@ <h5 class="subsection-title">Properties:</h5>
31723203

31733204
<dt class="tag-source">Source:</dt>
31743205
<dd class="tag-source"><ul class="dummy"><li>
3175-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line647">line 647</a>
3206+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line672">line 672</a>
31763207
</li></ul></dd>
31773208

31783209

@@ -3246,7 +3277,7 @@ <h4 class="name" id="simpleCallback"><span class="type-signature"></span>simpleC
32463277

32473278
<dt class="tag-source">Source:</dt>
32483279
<dd class="tag-source"><ul class="dummy"><li>
3249-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line726">line 726</a>
3280+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line752">line 752</a>
32503281
</li></ul></dd>
32513282

32523283

@@ -3429,7 +3460,7 @@ <h5>Parameters:</h5>
34293460

34303461
<dt class="tag-source">Source:</dt>
34313462
<dd class="tag-source"><ul class="dummy"><li>
3432-
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line677">line 677</a>
3463+
<a href="tmp.js.html">tmp.js</a>, <a href="tmp.js.html#line703">line 703</a>
34333464
</li></ul></dd>
34343465

34353466

@@ -3479,7 +3510,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
34793510
<br class="clear">
34803511

34813512
<footer>
3482-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Sat Feb 08 2020 01:04:48 GMT+0100 (GMT+01:00)
3513+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Apr 28 2020 19:39:35 GMT+0200 (GMT+02:00)
34833514
</footer>
34843515

34853516
<script> prettyPrint(); </script>

docs/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ <h2>Options</h2>
296296
absolute paths are fine as long as they point to a location under the system's default temporary directory.
297297
Any directories along the so specified path must exist, otherwise a ENOENT error will be thrown upon access,
298298
as tmp will not check the availability of the path, nor will it establish the requested path for you.</li>
299+
<li><code>tmpdir</code>: allows you to override the system's root tmp directory</li>
299300
<li><code>tries</code>: how many times should the function try to get a unique filename before giving up, default <code>3</code></li>
300301
<li><code>keep</code>: signals that the temporary file or directory should not be deleted on exit, default is <code>false</code>
301302
<ul>
@@ -322,7 +323,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
322323
<br class="clear">
323324

324325
<footer>
325-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Sat Feb 08 2020 01:04:48 GMT+0100 (GMT+01:00)
326+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Apr 28 2020 19:39:35 GMT+0200 (GMT+02:00)
326327
</footer>
327328

328329
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)