1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { BaseException } from '../exception';
|
---|
9 | import { TemplateTag } from '../utils/literals';
|
---|
10 | export declare class InvalidPathException extends BaseException {
|
---|
11 | constructor(path: string);
|
---|
12 | }
|
---|
13 | export declare class PathMustBeAbsoluteException extends BaseException {
|
---|
14 | constructor(path: string);
|
---|
15 | }
|
---|
16 | export declare class PathCannotBeFragmentException extends BaseException {
|
---|
17 | constructor(path: string);
|
---|
18 | }
|
---|
19 | /**
|
---|
20 | * A Path recognized by most methods in the DevKit.
|
---|
21 | */
|
---|
22 | export declare type Path = string & {
|
---|
23 | __PRIVATE_DEVKIT_PATH: void;
|
---|
24 | };
|
---|
25 | /**
|
---|
26 | * A Path fragment (file or directory name) recognized by most methods in the DevKit.
|
---|
27 | */
|
---|
28 | export declare type PathFragment = Path & {
|
---|
29 | __PRIVATE_DEVKIT_PATH_FRAGMENT: void;
|
---|
30 | };
|
---|
31 | /**
|
---|
32 | * The Separator for normalized path.
|
---|
33 | * @type {Path}
|
---|
34 | */
|
---|
35 | export declare const NormalizedSep: Path;
|
---|
36 | /**
|
---|
37 | * The root of a normalized path.
|
---|
38 | * @type {Path}
|
---|
39 | */
|
---|
40 | export declare const NormalizedRoot: Path;
|
---|
41 | /**
|
---|
42 | * Split a path into multiple path fragments. Each fragments except the last one will end with
|
---|
43 | * a path separator.
|
---|
44 | * @param {Path} path The path to split.
|
---|
45 | * @returns {Path[]} An array of path fragments.
|
---|
46 | */
|
---|
47 | export declare function split(path: Path): PathFragment[];
|
---|
48 | /**
|
---|
49 | *
|
---|
50 | */
|
---|
51 | export declare function extname(path: Path): string;
|
---|
52 | /**
|
---|
53 | * Return the basename of the path, as a Path. See path.basename
|
---|
54 | */
|
---|
55 | export declare function basename(path: Path): PathFragment;
|
---|
56 | /**
|
---|
57 | * Return the dirname of the path, as a Path. See path.dirname
|
---|
58 | */
|
---|
59 | export declare function dirname(path: Path): Path;
|
---|
60 | /**
|
---|
61 | * Join multiple paths together, and normalize the result. Accepts strings that will be
|
---|
62 | * normalized as well (but the original must be a path).
|
---|
63 | */
|
---|
64 | export declare function join(p1: Path, ...others: string[]): Path;
|
---|
65 | /**
|
---|
66 | * Returns true if a path is absolute.
|
---|
67 | */
|
---|
68 | export declare function isAbsolute(p: Path): boolean;
|
---|
69 | /**
|
---|
70 | * Returns a path such that `join(from, relative(from, to)) == to`.
|
---|
71 | * Both paths must be absolute, otherwise it does not make much sense.
|
---|
72 | */
|
---|
73 | export declare function relative(from: Path, to: Path): Path;
|
---|
74 | /**
|
---|
75 | * Returns a Path that is the resolution of p2, from p1. If p2 is absolute, it will return p2,
|
---|
76 | * otherwise will join both p1 and p2.
|
---|
77 | */
|
---|
78 | export declare function resolve(p1: Path, p2: Path): Path;
|
---|
79 | export declare function fragment(path: string): PathFragment;
|
---|
80 | /**
|
---|
81 | * Reset the cache. This is only useful for testing.
|
---|
82 | * @private
|
---|
83 | */
|
---|
84 | export declare function resetNormalizeCache(): void;
|
---|
85 | /**
|
---|
86 | * Normalize a string into a Path. This is the only mean to get a Path type from a string that
|
---|
87 | * represents a system path. This method cache the results as real world paths tend to be
|
---|
88 | * duplicated often.
|
---|
89 | * Normalization includes:
|
---|
90 | * - Windows backslashes `\\` are replaced with `/`.
|
---|
91 | * - Windows drivers are replaced with `/X/`, where X is the drive letter.
|
---|
92 | * - Absolute paths starts with `/`.
|
---|
93 | * - Multiple `/` are replaced by a single one.
|
---|
94 | * - Path segments `.` are removed.
|
---|
95 | * - Path segments `..` are resolved.
|
---|
96 | * - If a path is absolute, having a `..` at the start is invalid (and will throw).
|
---|
97 | * @param path The path to be normalized.
|
---|
98 | */
|
---|
99 | export declare function normalize(path: string): Path;
|
---|
100 | /**
|
---|
101 | * The no cache version of the normalize() function. Used for benchmarking and testing.
|
---|
102 | */
|
---|
103 | export declare function noCacheNormalize(path: string): Path;
|
---|
104 | export declare const path: TemplateTag<Path>;
|
---|
105 | export declare type WindowsPath = string & {
|
---|
106 | __PRIVATE_DEVKIT_WINDOWS_PATH: void;
|
---|
107 | };
|
---|
108 | export declare type PosixPath = string & {
|
---|
109 | __PRIVATE_DEVKIT_POSIX_PATH: void;
|
---|
110 | };
|
---|
111 | export declare function asWindowsPath(path: Path): WindowsPath;
|
---|
112 | export declare function asPosixPath(path: Path): PosixPath;
|
---|
113 | export declare function getSystemPath(path: Path): string;
|
---|