You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
997 B

  1. var mkdirp = require('../');
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. test('rel', function (t) {
  6. t.plan(2);
  7. var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  8. var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  9. var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  10. var cwd = process.cwd();
  11. process.chdir('/tmp');
  12. var file = [x,y,z].join('/');
  13. mkdirp(file, 0755, function (err) {
  14. if (err) t.fail(err);
  15. else path.exists(file, function (ex) {
  16. if (!ex) t.fail('file not created')
  17. else fs.stat(file, function (err, stat) {
  18. if (err) t.fail(err)
  19. else {
  20. process.chdir(cwd);
  21. t.equal(stat.mode & 0777, 0755);
  22. t.ok(stat.isDirectory(), 'target not a directory');
  23. t.end();
  24. }
  25. })
  26. })
  27. });
  28. });