Skip to content

Commit

Permalink
Prevent error from creating files/dirs under temp dir.
Browse files Browse the repository at this point in the history
Fix #130
  • Loading branch information
yuanchuan committed Feb 19, 2024
1 parent b4a53a3 commit bd85b60
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/has-native-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ module.exports = function hasNativeRecursive(fn) {
var child = stack.create('dir', parent);
var file = stack.create('file', child);

stack.mkdir(parent, child);
try {
stack.mkdir(parent, child);
} catch (e) {
stack = new TempStack();
// try again under current directory
TEMP_DIR = process.cwd();
parent = stack.create('dir', TEMP_DIR);
child = stack.create('dir', parent);
file = stack.create('file', child);
stack.mkdir(parent, child);
}

var options = { recursive: true };
var watcher;
Expand Down

0 comments on commit bd85b60

Please sign in to comment.