-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolve.mts
43 lines (40 loc) · 1.21 KB
/
resolve.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file resolve
* @module pathe/lib/resolve
*/
import resolveWith from '#lib/resolve-with'
/**
* Resolve a sequence of paths or path segments into an absolute path.
*
* The given sequence of paths is processed from right to left, with each
* subsequent path prepended until an absolute path is constructed.
*
* For instance, given the sequence of path segments: `/foo`, `/bar`, `baz`,
* calling `pathe.resolve('/foo', '/bar', 'baz')` would return `/bar/baz`
* because `'baz'` is not an absolute path, but `'/bar' + '/' + 'baz'` is.
*
* If, after processing all given `path` segments, an absolute path has not yet
* been generated, the current working directory is used.
*
* The resulting path is normalized and trailing separators are removed unless
* the path is resolved to the root directory.
*
* Zero-length `path` segments are ignored.
*
* If no `path` segments are passed, the absolute path of the current working
* directory is returned.
*
* @category
* core
*
* @this {void}
*
* @param {string[]} paths
* Sequence of paths or path segments
* @return {string}
* Absolute path
*/
function resolve(this: void, ...paths: string[]): string {
return resolveWith(paths)
}
export default resolve