diff --git a/doc/api/path.md b/doc/api/path.md index a5c5af6d068704..049d31a4708049 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -431,6 +431,39 @@ added: v0.11.15 The `path.posix` property provides access to POSIX specific implementations of the `path` methods. +*Note*: Be careful when using the following functions directly on Windows. + +### path.posix.resolve([...path]) +If after processing all given `path` segments an absolute path has not yet +been generated, `path.posix.resolve` will throw [`UNSUPPORTED_PLATFORM`] error. + +### path.posix.relative(from, to) +If `from` and `to` are both relative path, `path.posix.relative` will use the +path `/fakepath/` as the current working path to generate the result. + +For example + +``` +path.posix.relative('a/b/c', '../../x'); + +// 'from' will be '/fakepath/a/b/c' +// 'to' will be '/fakepath/../../x', then will be normalized to '/x' +// Returns: '../../../../x' +``` + +If one of `from` and `to` is relative path, `path.posix.relative` will use the +other absolute path as the current working path to generate the result. + +For example + +``` +path.posix.relative('/a/b/c', '../../x'); + +// 'from' will be '/a/b/c' +// 'to' will be '/a/b/c/../../x', then will be normalized to '/a/x' +// Returns: '../../x' +``` + ## path.relative(from, to)