Skip to content

Commit bd85b60

Browse files
committed
Prevent error from creating files/dirs under temp dir.
Fix #130
1 parent b4a53a3 commit bd85b60

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/has-native-recursive.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ module.exports = function hasNativeRecursive(fn) {
7676
var child = stack.create('dir', parent);
7777
var file = stack.create('file', child);
7878

79-
stack.mkdir(parent, child);
79+
try {
80+
stack.mkdir(parent, child);
81+
} catch (e) {
82+
stack = new TempStack();
83+
// try again under current directory
84+
TEMP_DIR = process.cwd();
85+
parent = stack.create('dir', TEMP_DIR);
86+
child = stack.create('dir', parent);
87+
file = stack.create('file', child);
88+
stack.mkdir(parent, child);
89+
}
8090

8191
var options = { recursive: true };
8292
var watcher;

0 commit comments

Comments
 (0)