| 1 |
"use strict"; |
| 2 |
|
| 3 |
var promisify = require("deferred").promisify |
| 4 |
, fs = require("fs") |
| 5 |
, path = require("path") |
| 6 |
, dirname = path.dirname |
| 7 |
, resolve = path.resolve |
| 8 |
, lstat = promisify(fs.lstat) |
| 9 |
, rmdir = promisify(fs.rmdir) |
| 10 |
, rootPath = resolve(__dirname, "./__playground/mkdir") |
| 11 |
, regular = resolve(rootPath, "foo") |
| 12 |
, existing = resolve(rootPath, "one") |
| 13 |
, deep = resolve(rootPath, "foo", "bar"); |
| 14 |
|
| 15 |
module.exports = function (t) { |
| 16 |
return { |
| 17 |
Regular: { |
| 18 |
Success: function (a, d) { |
| 19 |
t(regular)(function () { |
| 20 |
return lstat(regular)(function (stats) { |
| 21 |
a(stats.isDirectory(), true); |
| 22 |
return rmdir(regular); |
| 23 |
}); |
| 24 |
}).done(d, d); |
| 25 |
}, |
| 26 |
Error: function (a, d) { |
| 27 |
t(deep)(a.never, function () { a.ok(true, ""); }).done(d, d); |
| 28 |
}, |
| 29 |
Existing: function (a, d) { |
| 30 |
t(existing)(a.never, function () { a.ok(true, ""); }).done(d, d); |
| 31 |
} |
| 32 |
}, |
| 33 |
Intermediate: { |
| 34 |
"": function (a, d) { |
| 35 |
t(deep, { intermediate: true })(function () { |
| 36 |
return lstat(deep)(function (stats) { |
| 37 |
a(stats.isDirectory(), true); |
| 38 |
return rmdir(deep)(function () { return rmdir(dirname(deep)); }); |
| 39 |
}); |
| 40 |
}).done(d, d); |
| 41 |
}, |
| 42 |
"Existing": function (a, d) { |
| 43 |
t(existing, { intermediate: true })(function () { a.ok(true, ""); }).done(d, d); |
| 44 |
} |
| 45 |
} |
| 46 |
}; |
| 47 |
}; |