-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdouble-link-sh.js
More file actions
29 lines (24 loc) · 791 Bytes
/
double-link-sh.js
File metadata and controls
29 lines (24 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @overview Creates a link to a link to the "sh" binary. Used to test the link
* resolver in this library.
* @license MIT-0
*/
import fs from "node:fs";
import path from "node:path";
import { exit } from "node:process";
import which from "which";
const root = path.resolve(import.meta.dirname, "..");
const temp = path.resolve(root, ".temp", "double-link");
if (!fs.existsSync(temp)) {
fs.mkdirSync(temp, { recursive: true });
}
const shell = which.sync("sh", { nothrow: true });
if (shell === null) {
exit(0);
}
const linkToShell = path.resolve(temp, "link-to-shell");
const linkToLink = path.resolve(temp, "link-to-link");
if (!fs.existsSync(linkToLink)) {
fs.symlinkSync(shell, linkToShell);
fs.symlinkSync(`.${path.sep}${path.basename(linkToShell)}`, linkToLink);
}