1 var mkdirp = require('../');
2 var path = require('path');
3 var fs = require('fs');
4 var exists = fs.exists || path.exists;
5 var test = require('tap').test;
7 test('implicit mode from umask', function (t) {
9 var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10 var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
11 var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
13 var file = '/tmp/' + [x,y,z].join('/');
15 mkdirp(file, function (err) {
17 exists(file, function (ex) {
18 t.ok(ex, 'file created');
19 fs.stat(file, function (err, stat) {
21 t.equal(stat.mode & 0777, 0777 & (~process.umask()));
22 t.ok(stat.isDirectory(), 'target not a directory');