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