Skip to content

Commit ab060bf

Browse files
Granjowtargos
authored andcommitted
doc: clarify fs.symlink() usage
PR-URL: #29700 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 3f02855 commit ab060bf

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

doc/api/fs.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,22 +3249,32 @@ changes:
32493249
* `callback` {Function}
32503250
* `err` {Error}
32513251

3252-
Asynchronous symlink(2). No arguments other than a possible exception are given
3253-
to the completion callback. The `type` argument is only available on Windows
3254-
and ignored on other platforms. It can be set to `'dir'`, `'file'`, or
3255-
`'junction'`. If the `type` argument is not set, Node will autodetect `target`
3256-
type and use `'file'` or `'dir'`. If the `target` does not exist, `'file'` will
3257-
be used. Windows junction points require the destination path to be absolute.
3258-
When using `'junction'`, the `target` argument will automatically be normalized
3259-
to absolute path.
3252+
Asynchronous symlink(2) which creates the link called `path` pointing to
3253+
`target`. No arguments other than a possible exception are given to the
3254+
completion callback.
32603255

3261-
Here is an example below:
3256+
The `type` argument is only available on Windows and ignored on other platforms.
3257+
It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
3258+
not set, Node will autodetect `target` type and use `'file'` or `'dir'`. If the
3259+
`target` does not exist, `'file'` will be used. Windows junction points require
3260+
the destination path to be absolute. When using `'junction'`, the `target`
3261+
argument will automatically be normalized to absolute path.
3262+
3263+
Relative targets are relative to the link’s parent directory.
32623264

32633265
```js
3264-
fs.symlink('./foo', './new-port', callback);
3266+
fs.symlink('./mew', './example/mewtwo', callback);
32653267
```
32663268

3267-
It creates a symbolic link named "new-port" that points to "foo".
3269+
The above example creates a symbolic link `mewtwo` in the `example` which points
3270+
to `mew` in the same directory:
3271+
3272+
```bash
3273+
$ tree example/
3274+
example/
3275+
├── mew
3276+
└── mewtwo -> ./mew
3277+
```
32683278

32693279
## fs.symlinkSync(target, path[, type])
32703280
<!-- YAML

0 commit comments

Comments
 (0)