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