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.

39 lines
1.0 KiB

  1. var mkdirp = require('../');
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. test('sync perm', function (t) {
  6. t.plan(2);
  7. var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json';
  8. mkdirp.sync(file, 0755);
  9. path.exists(file, function (ex) {
  10. if (!ex) t.fail('file not created')
  11. else fs.stat(file, function (err, stat) {
  12. if (err) t.fail(err)
  13. else {
  14. t.equal(stat.mode & 0777, 0755);
  15. t.ok(stat.isDirectory(), 'target not a directory');
  16. t.end();
  17. }
  18. })
  19. });
  20. });
  21. test('sync root perm', function (t) {
  22. t.plan(1);
  23. var file = '/tmp';
  24. mkdirp.sync(file, 0755);
  25. path.exists(file, function (ex) {
  26. if (!ex) t.fail('file not created')
  27. else fs.stat(file, function (err, stat) {
  28. if (err) t.fail(err)
  29. else {
  30. t.ok(stat.isDirectory(), 'target not a directory');
  31. t.end();
  32. }
  33. })
  34. });
  35. });