Debian Codegraph @

ncjsm/test/_lib/setup-playground-dir-symlinks.js

raw
1 "use strict";
2
3 const { resolve } = require("path")
4 , symlink = require("fs2/symlink")
5 , unlink = require("fs2/unlink");
6
7 const playgroundDir = resolve(__dirname, "../__playground"), symlinkOptions = { type: "junction" };
8
9 const links = [
10 {
11 destination: resolve(playgroundDir, "another-deep-dir-link"),
12 source: "deep-dir-link-target"
13 },
14 { destination: resolve(playgroundDir, "deep-dir-link"), source: "another-deep-dir-link" },
15 { destination: resolve(playgroundDir, "invalid-dir-link"), source: "non-existing-dir" },
16 { destination: resolve(playgroundDir, "valid-dir-link"), source: "dir-link-target" }
17 ];
18
19 module.exports = {
20 setup: () =>
21 Promise.all(
22 links.map(({ source, destination }) => symlink(source, destination, symlinkOptions))
23 ),
24 teardown: () => Promise.all(links.map(({ destination }) => unlink(destination)))
25 };