* Check if symlinks are supported on the current platform. * On Windows without admin rights, symlink creation will fail with EPERM.
()
| 9 | * On Windows without admin rights, symlink creation will fail with EPERM. |
| 10 | */ |
| 11 | function 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 |
| 31 | const symlinksSupported = checkSymlinkSupport(); |
no outgoing calls
no test coverage detected