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

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