MCPcopy Create free account
hub / github.com/bytebase/dbhub / checkSymlinkSupport

Function checkSymlinkSupport

src/utils/__tests__/ssh-config-parser.test.ts:11–28  ·  view source on GitHub ↗

* Check if symlinks are supported on the current platform. * On Windows without admin rights, symlink creation will fail with EPERM.

()

Source from the content-addressed store, hash-verified

9 * On Windows without admin rights, symlink creation will fail with EPERM.
10 */
11function checkSymlinkSupport(): boolean {
12 const testDir = mkdtempSync(join(tmpdir(), 'symlink-check-'));
13 const targetFile = join(testDir, 'target');
14 const linkFile = join(testDir, 'link');
15
16 try {
17 writeFileSync(targetFile, 'test');
18 symlinkSync(targetFile, linkFile);
19 unlinkSync(linkFile);
20 unlinkSync(targetFile);
21 rmSync(testDir, { recursive: true });
22 return true;
23 } catch (error) {
24 rmSync(testDir, { recursive: true, force: true });
25 const e = error as NodeJS.ErrnoException;
26 return !(e.code === 'EPERM' || e.code === 'ENOTSUP');
27 }
28}
29
30// Check symlink support once at module load time
31const symlinksSupported = checkSymlinkSupport();

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected