Skip to content

Commit

Permalink
doc: clarify fs.symlink() usage
Browse files Browse the repository at this point in the history
PR-URL: #29700
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Granjow authored and targos committed Oct 1, 2019
1 parent 3f02855 commit ab060bf
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3249,22 +3249,32 @@ changes:
* `callback` {Function}
* `err` {Error}

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

Here is an example below:
The `type` argument is only available on Windows and ignored on other platforms.
It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
not set, Node will autodetect `target` type and use `'file'` or `'dir'`. If the
`target` does not exist, `'file'` will be used. Windows junction points require
the destination path to be absolute. When using `'junction'`, the `target`
argument will automatically be normalized to absolute path.

Relative targets are relative to the link’s parent directory.

```js
fs.symlink('./foo', './new-port', callback);
fs.symlink('./mew', './example/mewtwo', callback);
```

It creates a symbolic link named "new-port" that points to "foo".
The above example creates a symbolic link `mewtwo` in the `example` which points
to `mew` in the same directory:

```bash
$ tree example/
example/
├── mew
└── mewtwo -> ./mew
```

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

0 comments on commit ab060bf

Please sign in to comment.