PathResolver
Provides a file path resolver that is NPM module aware.
Example:
const pathResolver = new PathResolver('.', 'foo/bar.js', 'foo-bar', 'foo/bar.js');
pathResolver.importPath; // 'foo-bar'
pathResolver.filePath; // 'foo/bar.js'
pathResolver.resolve('./baz.js'); // 'foo/baz.js'
Constructor Summary
Public Constructor | ||
public |
constructor(rootPath: string, filePath: string, packageName: string, mainFilePath: string) Instantiate PathResolver. |
Member Summary
Public Members | ||
public get |
absolutePath: string: * Gets the absolute file path. |
|
public get |
Gets the file path that is the relative path from the root dir. |
|
public get |
importPath: string: * Gets import path that is considered package name or main file and path prefix. |
Private Members | ||
private |
|
|
private |
|
|
private |
_packageName: NPMPackageObject |
|
private |
|
Method Summary
Public Methods | ||
public |
Resolves the given file path with the data initialized in PathResolver. |
|
public |
resolveAbsolutePath(relativePath: string): string Resolve absolute path given the file path on this file. |
|
public |
setPathData(rootPath: string, filePath: string, packageName: string, mainFilePath: string) Sets the given path data to this PathResolver. |
Private Methods | ||
private |
Converts 'back slash' to 'slash' as necessary if the OS platform is windows. |
Public Constructors
Public Members
public get filePath: string: * source
Gets the file path that is the relative path from the root dir.
public get importPath: string: * source
Gets import path that is considered package name or main file and path prefix.
Private Members
private _packageName: NPMPackageObject source
Public Methods
public resolve(relativePath: string): string source
Resolves the given file path with the data initialized in PathResolver.
Params:
Name | Type | Attribute | Description |
relativePath | string | relative path on this file. |
public resolveAbsolutePath(relativePath: string): string source
Resolve absolute path given the file path on this file.
Params:
Name | Type | Attribute | Description |
relativePath | string | relative path on this file. |
public setPathData(rootPath: string, filePath: string, packageName: string, mainFilePath: string) source
Sets the given path data to this PathResolver.