UNPKG

2.2 kBTypeScriptView Raw
1/// <amd-module name="@angular/compiler-cli/src/ngtsc/file_system/src/helpers" />
2import { AbsoluteFsPath, FileSystem, PathSegment, PathString } from './types';
3export declare function getFileSystem(): FileSystem;
4export declare function setFileSystem(fileSystem: FileSystem): void;
5/**
6 * Convert the path `path` to an `AbsoluteFsPath`, throwing an error if it's not an absolute path.
7 */
8export declare function absoluteFrom(path: string): AbsoluteFsPath;
9/**
10 * Extract an `AbsoluteFsPath` from a `ts.SourceFile`-like object.
11 */
12export declare function absoluteFromSourceFile(sf: {
13 fileName: string;
14}): AbsoluteFsPath;
15/**
16 * Convert the path `path` to a `PathSegment`, throwing an error if it's not a relative path.
17 */
18export declare function relativeFrom(path: string): PathSegment;
19/**
20 * Static access to `dirname`.
21 */
22export declare function dirname<T extends PathString>(file: T): T;
23/**
24 * Static access to `join`.
25 */
26export declare function join<T extends PathString>(basePath: T, ...paths: string[]): T;
27/**
28 * Static access to `resolve`s.
29 */
30export declare function resolve(basePath: string, ...paths: string[]): AbsoluteFsPath;
31/** Returns true when the path provided is the root path. */
32export declare function isRoot(path: AbsoluteFsPath): boolean;
33/**
34 * Static access to `isRooted`.
35 */
36export declare function isRooted(path: string): boolean;
37/**
38 * Static access to `relative`.
39 */
40export declare function relative<T extends PathString>(from: T, to: T): PathSegment | AbsoluteFsPath;
41/**
42 * Static access to `basename`.
43 */
44export declare function basename(filePath: PathString, extension?: string): PathSegment;
45/**
46 * Returns true if the given path is locally relative.
47 *
48 * This is used to work out if the given path is relative (i.e. not absolute) but also is not
49 * escaping the current directory.
50 */
51export declare function isLocalRelativePath(relativePath: string): boolean;
52/**
53 * Converts a path to a form suitable for use as a relative module import specifier.
54 *
55 * In other words it adds the `./` to the path if it is locally relative.
56 */
57export declare function toRelativeImport(relativePath: PathSegment | AbsoluteFsPath): PathSegment | AbsoluteFsPath;