@@ -2,9 +2,10 @@ var tmp = require("tmp");
2
2
var Promise = require ( "bluebird" ) ;
3
3
4
4
5
- // file
5
+ // file
6
6
module . exports . fileSync = tmp . fileSync ;
7
7
var file = Promise . promisify ( tmp . file , { multiArgs : true } ) ;
8
+
8
9
module . exports . file = function file$promise ( ) {
9
10
return file . apply ( tmp , arguments ) . spread ( function ( path , fd , cleanup ) {
10
11
return { path : path , fd : fd , cleanup : cleanup } ;
@@ -13,16 +14,21 @@ module.exports.file = function file$promise() {
13
14
14
15
module . exports . withFile = function withFile ( fn ) {
15
16
var cleanup ;
16
- return module . exports . file . apply ( tmp ) . then ( function context ( o ) {
17
+
18
+ var params = Array . prototype . slice . call ( arguments , 1 ) ;
19
+
20
+ return module . exports . file . apply ( tmp , params ) . then ( function context ( o ) {
17
21
cleanup = o . cleanup ;
18
22
delete o . cleanup ;
19
23
return fn ( o ) ;
20
24
} ) . finally ( cleanup ) ;
21
25
} ;
22
26
23
- // directory
27
+
28
+ // directory
24
29
module . exports . dirSync = tmp . dirSync ;
25
30
var dir = Promise . promisify ( tmp . dir , { multiArgs : true } ) ;
31
+
26
32
module . exports . dir = function dir$promise ( ) {
27
33
return dir . apply ( tmp , arguments ) . spread ( function ( path , cleanup ) {
28
34
return { path : path , cleanup : cleanup } ;
@@ -31,19 +37,21 @@ module.exports.dir = function dir$promise() {
31
37
32
38
module . exports . withDir = function withDir ( fn ) {
33
39
var cleanup ;
34
- return module . exports . dir . apply ( tmp , arguments ) . then ( function context ( o ) {
40
+
41
+ var params = Array . prototype . slice . call ( arguments , 1 ) ;
42
+
43
+ return module . exports . dir . apply ( tmp , params ) . then ( function context ( o ) {
35
44
cleanup = o . cleanup ;
36
45
delete o . cleanup ;
37
46
return fn ( o ) ;
38
47
} ) . finally ( cleanup ) ;
39
48
} ;
40
49
50
+
41
51
// name generation
42
52
module . exports . tmpNameSync = tmp . tmpNameSync ;
43
53
module . exports . tmpName = Promise . promisify ( tmp . tmpName ) ;
44
54
45
-
46
55
module . exports . tmpdir = tmp . tmpdir ;
47
56
48
-
49
57
module . exports . setGracefulCleanup = tmp . setGracefulCleanup ;
0 commit comments