@vbarbarosh/node-helpers
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,3 +5,3 @@ { | ||
"name": "@vbarbarosh/node-helpers", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A set of helpers for JavaScript/Node.js", | ||
@@ -8,0 +8,0 @@ "files": [ |
@@ -22,4 +22,9 @@ const fs_exists = require('./fs_exists'); | ||
// Error: EEXIST: file already exists, mkdir [...] | ||
if (error.code == 'EEXIST') { | ||
break; | ||
if (error.code === 'EEXIST') { | ||
// Exiting here is not correct. When two processes are running in parallel, | ||
// one tries to create `a/b/c` and another `a`. When second process creates | ||
// `a`, the first process will get `EEXIST` and stops (break) creating any | ||
// nested directories, which is not correct. | ||
// break; | ||
continue; | ||
} | ||
@@ -26,0 +31,0 @@ throw error; |
@@ -15,2 +15,11 @@ const assert = require('assert'); | ||
}); | ||
it('should create the same directory structure in parallel', async function () { | ||
await fs_tempdir(async function (d) { | ||
const tmp = fs_path_resolve(d, 'a/b/c/d/e/f/g/h'); | ||
await Promise.all(Array(10).fill(tmp).map(async function (v, i) { | ||
await fs_mkdirp(tmp); | ||
assert(await fs_fi(tmp).then(v => v.isDirectory())); | ||
})); | ||
}); | ||
}); | ||
}); |
59532
1698