(target, path, type)
| 1735 | } |
| 1736 | |
| 1737 | async function symlink(target, path, type) { |
| 1738 | const h = vfsState.handlers; |
| 1739 | if (h !== null) { |
| 1740 | const promise = h.symlink(target, path, type); |
| 1741 | if (promise !== undefined) { await promise; return; } |
| 1742 | } |
| 1743 | validateOneOf(type, 'type', ['dir', 'file', 'junction', null, undefined]); |
| 1744 | if (isWindows && type == null) { |
| 1745 | try { |
| 1746 | const absoluteTarget = pathModule.resolve(`${path}`, '..', `${target}`); |
| 1747 | type = (await stat(absoluteTarget)).isDirectory() ? 'dir' : 'file'; |
| 1748 | } catch { |
| 1749 | // Default to 'file' if path is invalid or file does not exist |
| 1750 | type = 'file'; |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | // Due to the nature of Node.js runtime, symlinks has different edge cases that can bypass |
| 1755 | // the permission model security guarantees. Thus, this API is disabled unless fs.read |
| 1756 | // and fs.write permission has been given. |
| 1757 | if (permission.isEnabled() && !permission.has('fs')) { |
| 1758 | throw new ERR_ACCESS_DENIED('fs.symlink API requires full fs.read and fs.write permissions.'); |
| 1759 | } |
| 1760 | |
| 1761 | target = getValidatedPath(target, 'target'); |
| 1762 | path = getValidatedPath(path); |
| 1763 | return await PromisePrototypeThen( |
| 1764 | binding.symlink( |
| 1765 | preprocessSymlinkDestination(target, type, path), |
| 1766 | path, |
| 1767 | stringToSymlinkType(type), |
| 1768 | kUsePromises, |
| 1769 | ), |
| 1770 | undefined, |
| 1771 | handleErrorFromBinding, |
| 1772 | ); |
| 1773 | } |
| 1774 | |
| 1775 | async function fstat(handle, options = { __proto__: null, bigint: false }) { |
| 1776 | const result = await PromisePrototypeThen( |
no test coverage detected
searching dependent graphs…