Ohm-Management - Projektarbeit B-ME
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.

chmod.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var mkdirp = require('../').mkdirp;
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. var _0777 = parseInt('0777', 8);
  6. var _0755 = parseInt('0755', 8);
  7. var _0744 = parseInt('0744', 8);
  8. var ps = [ '', 'tmp' ];
  9. for (var i = 0; i < 25; i++) {
  10. var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  11. ps.push(dir);
  12. }
  13. var file = ps.join('/');
  14. test('chmod-pre', function (t) {
  15. var mode = _0744
  16. mkdirp(file, mode, function (er) {
  17. t.ifError(er, 'should not error');
  18. fs.stat(file, function (er, stat) {
  19. t.ifError(er, 'should exist');
  20. t.ok(stat && stat.isDirectory(), 'should be directory');
  21. t.equal(stat && stat.mode & _0777, mode, 'should be 0744');
  22. t.end();
  23. });
  24. });
  25. });
  26. test('chmod', function (t) {
  27. var mode = _0755
  28. mkdirp(file, mode, function (er) {
  29. t.ifError(er, 'should not error');
  30. fs.stat(file, function (er, stat) {
  31. t.ifError(er, 'should exist');
  32. t.ok(stat && stat.isDirectory(), 'should be directory');
  33. t.end();
  34. });
  35. });
  36. });