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.

37 lines
821 B

  1. var mkdirp = require('../').mkdirp;
  2. var path = require('path');
  3. var fs = require('fs');
  4. var test = require('tap').test;
  5. var ps = [ '', 'tmp' ];
  6. for (var i = 0; i < 25; i++) {
  7. var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  8. ps.push(dir);
  9. }
  10. var file = ps.join('/');
  11. // a file in the way
  12. var itw = ps.slice(0, 3).join('/');
  13. test('clobber-pre', function (t) {
  14. console.error("about to write to "+itw)
  15. fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.');
  16. fs.stat(itw, function (er, stat) {
  17. t.ifError(er)
  18. t.ok(stat && stat.isFile(), 'should be file')
  19. t.end()
  20. })
  21. })
  22. test('clobber', function (t) {
  23. t.plan(2);
  24. mkdirp(file, 0755, function (err) {
  25. t.ok(err);
  26. t.equal(err.code, 'ENOTDIR');
  27. t.end();
  28. });
  29. });