Reference Source Test
import PathResolver from 'esdoc2/out/src/Util/PathResolver.js'
public class | source

PathResolver

file path resolver.

Example:

let pathResolver = new PathResolver('./src', 'foo/bar.js', 'foo-bar', 'foo/bar.js');
pathResolver.importPath; // 'foo-bar'
pathResolver.filePath; // 'src/foo/bar.js'
pathResolver.resolve('./baz.js'); // 'src/foo/baz.js'

Constructor Summary

Public Constructor
public

constructor(inDirPath: string, filePath: string, packageName: string, mainFilePath: string)

create instance.

Member Summary

Public Members
public get

file full path.

public get

file path that is relative path on root dir.

public get

import path that is considered package name, main file and path prefix.

Private Members
private
private
private
private

Method Summary

Public Methods
public

resolve(relativePath: string): *

resolve file path on this file.

Private Methods
private

_slash(filePath: string): string

convert 'back slash' to 'slash'.

Public Constructors

public constructor(inDirPath: string, filePath: string, packageName: string, mainFilePath: string) source

create instance.

Params:

NameTypeAttributeDescription
inDirPath string

root directory path.

filePath string

relative file path from root directory path.

packageName string
  • optional

npm package name.

mainFilePath string
  • optional

npm main file path.

Public Members

public get fileFullPath: string source

file full path.

public get filePath: string source

file path that is relative path on root dir.

public get importPath: string source

import path that is considered package name, main file and path prefix.

Private Members

private _filePath: string source

private _inDirPath: string source

private _mainFilePath: string source

private _packageName: NPMPackageObject source

Public Methods

public resolve(relativePath: string): * source

resolve file path on this file.

Params:

NameTypeAttributeDescription
relativePath string

relative path on this file.

Return:

*

Private Methods

private _slash(filePath: string): string source

convert 'back slash' to 'slash'. path separator is 'back slash' if platform is windows.

Params:

NameTypeAttributeDescription
filePath string

target file path.

Return:

string

converted path.