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.

38 lines
1.0 KiB

  1. var mkdirp = require('../').mkdirp;
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. var ps = [ '', 'tmp' ];
  6. for (var i = 0; i < 25; i++) {
  7. var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  8. ps.push(dir);
  9. }
  10. var file = ps.join('/');
  11. test('chmod-pre', function (t) {
  12. var mode = 0744
  13. mkdirp(file, mode, function (er) {
  14. t.ifError(er, 'should not error');
  15. fs.stat(file, function (er, stat) {
  16. t.ifError(er, 'should exist');
  17. t.ok(stat && stat.isDirectory(), 'should be directory');
  18. t.equal(stat && stat.mode & 0777, mode, 'should be 0744');
  19. t.end();
  20. });
  21. });
  22. });
  23. test('chmod', function (t) {
  24. var mode = 0755
  25. mkdirp(file, mode, function (er) {
  26. t.ifError(er, 'should not error');
  27. fs.stat(file, function (er, stat) {
  28. t.ifError(er, 'should exist');
  29. t.ok(stat && stat.isDirectory(), 'should be directory');
  30. t.end();
  31. });
  32. });
  33. });