arnaucube
arnaucube/comunicationLeapPublic Self-hosted repository
comunicationLeap/node_modules/mkdirp/test/umask_sync.js
node_modules/mkdirp/test/umask_sync.jsRaw
 1var mkdirp = require('../');
 2var path = require('path');
 3var fs = require('fs');
 4var test = require('tap').test;
 5
 6test('umask sync modes', function (t) {
 7    t.plan(2);
 8    var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
 9    var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10    var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
11
12    var file = '/tmp/' + [x,y,z].join('/');
13
14    try {
15        mkdirp.sync(file);
16    } catch (err) {
17        t.fail(err);
18        return t.end();
19    }
20
21    path.exists(file, function (ex) {
22        if (!ex) t.fail('file not created')
23        else fs.stat(file, function (err, stat) {
24            if (err) t.fail(err)
25            else {
26                t.equal(stat.mode & 0777, (0777 & (~process.umask())));
27                t.ok(stat.isDirectory(), 'target not a directory');
28                t.end();
29            }
30        });
31    });
32});