1 | declare module 'path/posix' {
|
2 | import path = require('path');
|
3 | export = path;
|
4 | }
|
5 |
|
6 | declare module 'path/win32' {
|
7 | import path = require('path');
|
8 | export = path;
|
9 | }
|
10 |
|
11 | declare module 'path' {
|
12 | namespace path {
|
13 | /**
|
14 | * A parsed path object generated by path.parse() or consumed by path.format().
|
15 | */
|
16 | interface ParsedPath {
|
17 | /**
|
18 | * The root of the path such as '/' or 'c:\'
|
19 | */
|
20 | root: string;
|
21 | /**
|
22 | * The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
23 | */
|
24 | dir: string;
|
25 | /**
|
26 | * The file name including extension (if any) such as 'index.html'
|
27 | */
|
28 | base: string;
|
29 | /**
|
30 | * The file extension (if any) such as '.html'
|
31 | */
|
32 | ext: string;
|
33 | /**
|
34 | * The file name without extension (if any) such as 'index'
|
35 | */
|
36 | name: string;
|
37 | }
|
38 |
|
39 | interface FormatInputPathObject {
|
40 | /**
|
41 | * The root of the path such as '/' or 'c:\'
|
42 | */
|
43 | root?: string;
|
44 | /**
|
45 | * The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
46 | */
|
47 | dir?: string;
|
48 | /**
|
49 | * The file name including extension (if any) such as 'index.html'
|
50 | */
|
51 | base?: string;
|
52 | /**
|
53 | * The file extension (if any) such as '.html'
|
54 | */
|
55 | ext?: string;
|
56 | /**
|
57 | * The file name without extension (if any) such as 'index'
|
58 | */
|
59 | name?: string;
|
60 | }
|
61 |
|
62 | interface PlatformPath {
|
63 | /**
|
64 | * Normalize a string path, reducing '..' and '.' parts.
|
65 | * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
66 | *
|
67 | * @param p string path to normalize.
|
68 | */
|
69 | normalize(p: string): string;
|
70 | /**
|
71 | * Join all arguments together and normalize the resulting path.
|
72 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
73 | *
|
74 | * @param paths paths to join.
|
75 | */
|
76 | join(...paths: string[]): string;
|
77 | /**
|
78 | * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
79 | *
|
80 | * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
|
81 | *
|
82 | * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
|
83 | * until an absolute path is found. If after using all {from} paths still no absolute path is found,
|
84 | * the current working directory is used as well. The resulting path is normalized,
|
85 | * and trailing slashes are removed unless the path gets resolved to the root directory.
|
86 | *
|
87 | * @param pathSegments string paths to join. Non-string arguments are ignored.
|
88 | */
|
89 | resolve(...pathSegments: string[]): string;
|
90 | /**
|
91 | * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
92 | *
|
93 | * @param path path to test.
|
94 | */
|
95 | isAbsolute(p: string): boolean;
|
96 | /**
|
97 | * Solve the relative path from {from} to {to}.
|
98 | * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
99 | */
|
100 | relative(from: string, to: string): string;
|
101 | /**
|
102 | * Return the directory name of a path. Similar to the Unix dirname command.
|
103 | *
|
104 | * @param p the path to evaluate.
|
105 | */
|
106 | dirname(p: string): string;
|
107 | /**
|
108 | * Return the last portion of a path. Similar to the Unix basename command.
|
109 | * Often used to extract the file name from a fully qualified path.
|
110 | *
|
111 | * @param p the path to evaluate.
|
112 | * @param ext optionally, an extension to remove from the result.
|
113 | */
|
114 | basename(p: string, ext?: string): string;
|
115 | /**
|
116 | * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
117 | * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
|
118 | *
|
119 | * @param p the path to evaluate.
|
120 | */
|
121 | extname(p: string): string;
|
122 | /**
|
123 | * The platform-specific file separator. '\\' or '/'.
|
124 | */
|
125 | readonly sep: string;
|
126 | /**
|
127 | * The platform-specific file delimiter. ';' or ':'.
|
128 | */
|
129 | readonly delimiter: string;
|
130 | /**
|
131 | * Returns an object from a path string - the opposite of format().
|
132 | *
|
133 | * @param pathString path to evaluate.
|
134 | */
|
135 | parse(p: string): ParsedPath;
|
136 | /**
|
137 | * Returns a path string from an object - the opposite of parse().
|
138 | *
|
139 | * @param pathString path to evaluate.
|
140 | */
|
141 | format(pP: FormatInputPathObject): string;
|
142 | /**
|
143 | * On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
|
144 | * If path is not a string, path will be returned without modifications.
|
145 | * This method is meaningful only on Windows system.
|
146 | * On POSIX systems, the method is non-operational and always returns path without modifications.
|
147 | */
|
148 | toNamespacedPath(path: string): string;
|
149 | /**
|
150 | * Posix specific pathing.
|
151 | * Same as parent object on posix.
|
152 | */
|
153 | readonly posix: PlatformPath;
|
154 | /**
|
155 | * Windows specific pathing.
|
156 | * Same as parent object on windows
|
157 | */
|
158 | readonly win32: PlatformPath;
|
159 | }
|
160 | }
|
161 | const path: path.PlatformPath;
|
162 | export = path;
|
163 | }
|