💾 Archived View for gmi.noulin.net › gitRepositories › git-off › file › src › node_modules › mkdirp … captured on 2024-09-29 at 01:12:36. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
race.js (988B)
1 var mkdirp = require('../').mkdirp; 2 var path = require('path'); 3 var fs = require('fs'); 4 var exists = fs.exists || path.exists; 5 var test = require('tap').test; 6 var _0777 = parseInt('0777', 8); 7 var _0755 = parseInt('0755', 8); 8 9 test('race', function (t) { 10 t.plan(10); 11 var ps = [ '', 'tmp' ]; 12 13 for (var i = 0; i < 25; i++) { 14 var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 15 ps.push(dir); 16 } 17 var file = ps.join('/'); 18 19 var res = 2; 20 mk(file); 21 22 mk(file); 23 24 function mk (file, cb) { 25 mkdirp(file, _0755, function (err) { 26 t.ifError(err); 27 exists(file, function (ex) { 28 t.ok(ex, 'file created'); 29 fs.stat(file, function (err, stat) { 30 t.ifError(err); 31 t.equal(stat.mode & _0777, _0755); 32 t.ok(stat.isDirectory(), 'target not a directory'); 33 }); 34 }) 35 }); 36 } 37 });