a zip code crypto-currency system good for red ONLY

sync.js 906B

123456789101112131415161718192021222324252627282930313233
  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('sync', function (t) {
  9. t.plan(4);
  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. try {
  15. mkdirp.sync(file, _0755);
  16. } catch (err) {
  17. t.fail(err);
  18. return t.end();
  19. }
  20. exists(file, function (ex) {
  21. t.ok(ex, 'file created');
  22. fs.stat(file, function (err, stat) {
  23. t.ifError(err);
  24. t.equal(stat.mode & _0777, _0755);
  25. t.ok(stat.isDirectory(), 'target not a directory');
  26. });
  27. });
  28. });