| 1 |
"use strict"; |
| 2 |
|
| 3 |
var path = require("path") |
| 4 |
, fs = require("fs") |
| 5 |
, pg = path.resolve(__dirname, "./__playground/copy"); |
| 6 |
|
| 7 |
module.exports = { |
| 8 |
"Success": function (t, a, d) { |
| 9 |
var src = pg + "/sample.js", dst = pg + "/sample.copy.js"; |
| 10 |
t(src, dst, function (err) { |
| 11 |
if (err) { |
| 12 |
d(err); |
| 13 |
return; |
| 14 |
} |
| 15 |
fs.readFile(src, "utf8", function (err2, srcContent) { |
| 16 |
if (err2) { |
| 17 |
d(err2); |
| 18 |
return; |
| 19 |
} |
| 20 |
fs.readFile(dst, "utf8", function (err3, dstContent) { |
| 21 |
if (err3) { |
| 22 |
d(err3); |
| 23 |
return; |
| 24 |
} |
| 25 |
a(dstContent, srcContent, "Content"); |
| 26 |
|
| 27 |
fs.stat(src, function (err4, srcStats) { |
| 28 |
if (err4) { |
| 29 |
d(err4); |
| 30 |
return; |
| 31 |
} |
| 32 |
fs.stat(dst, function (err5, dstStats) { |
| 33 |
if (err5) { |
| 34 |
d(err5); |
| 35 |
return; |
| 36 |
} |
| 37 |
a(dstStats.mode, srcStats.mode); |
| 38 |
fs.unlink(dst, d); |
| 39 |
}); |
| 40 |
}); |
| 41 |
}); |
| 42 |
}); |
| 43 |
}); |
| 44 |
}, |
| 45 |
"Deep": function (t, a, d) { |
| 46 |
var src = pg + "/sample.js", dst = pg + "/deep/path/sample.copy.js"; |
| 47 |
return t(src, dst, { intermediate: true }).done(function () { |
| 48 |
fs.readFile(src, "utf8", function (err, srcContent) { |
| 49 |
if (err) { |
| 50 |
d(err); |
| 51 |
return; |
| 52 |
} |
| 53 |
fs.readFile(dst, "utf8", function (err2, dstContent) { |
| 54 |
if (err2) { |
| 55 |
d(err2); |
| 56 |
return; |
| 57 |
} |
| 58 |
a(dstContent, srcContent, "Content"); |
| 59 |
fs.unlink(dst, d); |
| 60 |
}); |
| 61 |
}); |
| 62 |
}, d); |
| 63 |
}, |
| 64 |
"Wrong path": function (t, a, d) { |
| 65 |
t(pg + "/sample.js", pg + "/:;\\//wrong-filename").done(a.never, function (e) { |
| 66 |
a(e.code, "ENOENT", "Path error"); |
| 67 |
d(); |
| 68 |
}); |
| 69 |
}, |
| 70 |
"Loose": function (t, a, d) { |
| 71 |
t(pg + "/:;\\//wrong-filename", pg + "/sample-test.js", { loose: true }).done(function ( |
| 72 |
result |
| 73 |
) { |
| 74 |
a(result, false); |
| 75 |
d(); |
| 76 |
}, d); |
| 77 |
}, |
| 78 |
"Loose with mode": function (t, a, d) { |
| 79 |
t(pg + "/:;\\//wrong-filename", pg + "/sample-test2.js", { loose: true, mode: 33188 }).done( |
| 80 |
function (result) { |
| 81 |
a(result, false); |
| 82 |
d(); |
| 83 |
}, |
| 84 |
d |
| 85 |
); |
| 86 |
} |
| 87 |
}; |