您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

umask.js 936B

12345678910111213141516171819202122232425262728
  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('implicit mode from umask', function (t) {
  9. t.plan(5);
  10. var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  11. var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  12. var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  13. var file = '/tmp/' + [x,y,z].join('/');
  14. mkdirp(file, function (err) {
  15. t.ifError(err);
  16. exists(file, function (ex) {
  17. t.ok(ex, 'file created');
  18. fs.stat(file, function (err, stat) {
  19. t.ifError(err);
  20. t.equal(stat.mode & _0777, _0777 & (~process.umask()));
  21. t.ok(stat.isDirectory(), 'target not a directory');
  22. });
  23. })
  24. });
  25. });