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.

28 lines
942 B

  1. var mkdirp = require('../');
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. test('implicit mode from umask', 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. mkdirp(file, function (err) {
  12. if (err) t.fail(err);
  13. else path.exists(file, function (ex) {
  14. if (!ex) t.fail('file not created')
  15. else fs.stat(file, function (err, stat) {
  16. if (err) t.fail(err)
  17. else {
  18. t.equal(stat.mode & 0777, 0777 & (~process.umask()));
  19. t.ok(stat.isDirectory(), 'target not a directory');
  20. t.end();
  21. }
  22. })
  23. })
  24. });
  25. });