| 1 |
"use strict"; |
| 2 |
|
| 3 |
const { resolve } = require("path") |
| 4 |
, symlink = require("../symlink") |
| 5 |
, unlink = require("../unlink"); |
| 6 |
|
| 7 |
const rootPath = resolve(__dirname, "./__playground/is-symlink") |
| 8 |
, targetFile = resolve(rootPath, "from") |
| 9 |
, nonSymlink = resolve(rootPath, "non-symlink") |
| 10 |
, symlink1 = resolve(rootPath, "sym1") |
| 11 |
, symlink2 = resolve(rootPath, "sym2"); |
| 12 |
|
| 13 |
module.exports = function (t, a, d) { |
| 14 |
symlink("from", symlink1) |
| 15 |
.then(() => symlink("sym1", symlink2)) |
| 16 |
.then(() => t(symlink2)) |
| 17 |
.then(result => { |
| 18 |
a(result, true); |
| 19 |
return t(symlink2, { linkPath: "sym1" }); |
| 20 |
}) |
| 21 |
.then(result => { |
| 22 |
a(result, true); |
| 23 |
return t(symlink2, { linkPath: targetFile }); |
| 24 |
}) |
| 25 |
.then(result => { |
| 26 |
a(result, false); |
| 27 |
return t(symlink2, { linkPath: symlink1 }); |
| 28 |
}) |
| 29 |
.then(result => { |
| 30 |
a(result, true); |
| 31 |
return t(symlink2, { linkPath: targetFile, recursive: true }); |
| 32 |
}) |
| 33 |
.then(result => { |
| 34 |
a(result, true); |
| 35 |
return t(targetFile); |
| 36 |
}) |
| 37 |
.then(result => { |
| 38 |
a(result, false); |
| 39 |
return t(`${ targetFile }/foo`); |
| 40 |
}) |
| 41 |
.then(result => { |
| 42 |
a(result, null); |
| 43 |
return unlink(symlink1)(unlink(symlink2)); |
| 44 |
}) |
| 45 |
.then(() => t(nonSymlink, { loose: true }))(result => { a(result, null); }) |
| 46 |
.done(d, d); |
| 47 |
}; |