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
876 B

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