Debian Codegraph @

ncjsm/test/_lib/setup-playground-file-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: "file" };
8
9 const links = [
10 {
11 destination: resolve(playgroundDir, "another-deep-file-link.js"),
12 source: "deep-file-link-target.js"
13 },
14 {
15 destination: resolve(playgroundDir, "deep-file-link.js"),
16 source: "another-deep-file-link.js"
17 },
18 {
19 destination: resolve(playgroundDir, "invalid-file-link-with-a-fallback.js"),
20 source: "non-existing-file.js"
21 },
22 { destination: resolve(playgroundDir, "invalid-file-link.js"), source: "non-existing-file.js" },
23 { destination: resolve(playgroundDir, "valid-file-link.js"), source: "file-link-target.js" }
24 ];
25
26 module.exports = {
27 setup: () =>
28 Promise.all(
29 links.map(({ source, destination }) => symlink(source, destination, symlinkOptions))
30 ),
31 teardown: () => Promise.all(links.map(({ destination }) => unlink(destination)))
32 };