mkpath.js 834 B

12345678910111213141516171819202122232425262728
  1. /* Tests borrowed from substack's node-mkdirp
  2. * https://github.com/substack/node-mkdirp */
  3. var mkpath = require('../');
  4. var fs = require('fs');
  5. var test = require('tap').test;
  6. test('woo', function (t) {
  7. t.plan(2);
  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. mkpath(file, 0755, function (err) {
  13. if (err) t.fail(err);
  14. else fs.stat(file, function (err, stat) {
  15. if (err) t.fail(err)
  16. else {
  17. t.equal(stat.mode & 0777, 0755);
  18. t.ok(stat.isDirectory(), 'target not a directory');
  19. t.end();
  20. }
  21. })
  22. });
  23. });