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.

1234567891011121314151617181920212223242526272829303132
  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('async perm', function (t) {
  9. t.plan(5);
  10. var file = '/tmp/' + (Math.random() * (1<<30)).toString(16);
  11. mkdirp(file, _0755, function (err) {
  12. t.ifError(err);
  13. exists(file, function (ex) {
  14. t.ok(ex, 'file created');
  15. fs.stat(file, function (err, stat) {
  16. t.ifError(err);
  17. t.equal(stat.mode & _0777, _0755);
  18. t.ok(stat.isDirectory(), 'target not a directory');
  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. });