88fa4324ee1901e60f184c0c60022adb99c84138
[yaffs-website] / node_modules / extract-zip / node_modules / mkdirp / test / sync.js
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
7 test('sync', function (t) {
8     t.plan(4);
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);
12
13     var file = '/tmp/' + [x,y,z].join('/');
14
15     try {
16         mkdirp.sync(file, 0755);
17     } catch (err) {
18         t.fail(err);
19         return t.end();
20     }
21
22     exists(file, function (ex) {
23         t.ok(ex, 'file created');
24         fs.stat(file, function (err, stat) {
25             t.ifError(err);
26             t.equal(stat.mode & 0777, 0755);
27             t.ok(stat.isDirectory(), 'target not a directory');
28         });
29     });
30 });