symlink
function symlink(
oldpath,
newpath,
options?): Promise<void>;
Create symbolic link from a file path.
On Windows platforms, you should specify the 3rd parameter "options" with below 3 options:
"file"or"dir": Pointing to CreateSymbolicLinkW function."junction": NTFS v5+ features roughly equivalent to Unix directory symbolic links.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| Original file path. |
|
| New symbolic link that pointing to the original file. |
|
| (Optional) Only used on Windows platforms, will be ignored on Unix platforms. By default is |
Returns
Promise<void>
It resolves to nothing.
Throws
Throws TypeError if any parameter is invalid. Or throws Error if failed to create symbolic link from the file.
Example
try {
// Linux
await Rsvim.fs.symlink("README.md", "linked-README.md");
// Windows
await Rsvim.fs.symlink("README.md", "linked-README.md", "junction");
Rsvim.cmd.echo(`Created symbolic link "linked-README.md" pointing to "README.md"`);
} catch (e) {
Rsvim.cmd.echo(`Failed to create symbolic link pointing to "README.md": ${e}`);
}