rel.js 918 B

12345678910111213141516171819202122232425262728293031
  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. test('rel', function (t) {
  7. t.plan(5);
  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. var cwd = process.cwd();
  12. process.chdir('/tmp');
  13. var file = [x,y,z].join('/');
  14. mkdirp(file, 0755, function (err) {
  15. t.ifError(err);
  16. exists(file, function (ex) {
  17. t.ok(ex, 'file created');
  18. fs.stat(file, function (err, stat) {
  19. t.ifError(err);
  20. process.chdir(cwd);
  21. t.equal(stat.mode & 0777, 0755);
  22. t.ok(stat.isDirectory(), 'target not a directory');
  23. })
  24. })
  25. });
  26. });