arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/mkdirp/test/umask.js
www/node_modules/mkdirp/test/umask.jsRaw
 1var mkdirp = require('../');
 2var path = require('path');
 3var fs = require('fs');
 4var exists = fs.exists || path.exists;
 5var test = require('tap').test;
 6var _0777 = parseInt('0777', 8);
 7var _0755 = parseInt('0755', 8);
 8
 9test('implicit mode from umask', function (t) {
10    t.plan(5);
11    var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
12    var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
13    var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
14    
15    var file = '/tmp/' + [x,y,z].join('/');
16    
17    mkdirp(file, function (err) {
18        t.ifError(err);
19        exists(file, function (ex) {
20            t.ok(ex, 'file created');
21            fs.stat(file, function (err, stat) {
22                t.ifError(err);
23                t.equal(stat.mode & _0777, _0777 & (~process.umask()));
24                t.ok(stat.isDirectory(), 'target not a directory');
25            });
26        })
27    });
28});