Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80684 views
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;
6
var _0777 = parseInt('0777', 8);
7
var _0755 = parseInt('0755', 8);
8
9
test('sync perm', function (t) {
10
t.plan(4);
11
var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json';
12
13
mkdirp.sync(file, _0755);
14
exists(file, function (ex) {
15
t.ok(ex, 'file created');
16
fs.stat(file, function (err, stat) {
17
t.ifError(err);
18
t.equal(stat.mode & _0777, _0755);
19
t.ok(stat.isDirectory(), 'target not a directory');
20
});
21
});
22
});
23
24
test('sync root perm', function (t) {
25
t.plan(3);
26
27
var file = '/tmp';
28
mkdirp.sync(file, _0755);
29
exists(file, function (ex) {
30
t.ok(ex, 'file created');
31
fs.stat(file, function (err, stat) {
32
t.ifError(err);
33
t.ok(stat.isDirectory(), 'target not a directory');
34
})
35
});
36
});
37
38