mkdirp.js 831 B

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