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.

36 lines
991 B

7 years ago
  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. test('sync perm', function (t) {
  9. t.plan(4);
  10. var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json';
  11. mkdirp.sync(file, _0755);
  12. exists(file, function (ex) {
  13. t.ok(ex, 'file created');
  14. fs.stat(file, function (err, stat) {
  15. t.ifError(err);
  16. t.equal(stat.mode & _0777, _0755);
  17. t.ok(stat.isDirectory(), 'target not a directory');
  18. });
  19. });
  20. });
  21. test('sync root perm', function (t) {
  22. t.plan(3);
  23. var file = '/tmp';
  24. mkdirp.sync(file, _0755);
  25. exists(file, function (ex) {
  26. t.ok(ex, 'file created');
  27. fs.stat(file, function (err, stat) {
  28. t.ifError(err);
  29. t.ok(stat.isDirectory(), 'target not a directory');
  30. })
  31. });
  32. });